I have a function:

function updateIata(input) { input.siblings('span.iata-code').css({ 'top': '1px', 'opacity': '0' }); $.getJSON('/json/cities.json', function(data) { for(var i = 0; i < data.length; i++) { if(data[i].name_translations.ru == input.val()) { input.siblings('span.iata-code').text(data[i].code).css({ 'top': '10px', 'opacity': '1' }); } } }); } 

In the body of which changes are made associated with the style of input. This function is called by the change event:

 $('input.iata-updater').on('change', function(){ updateIata($(this)); // нерабочий вариант }); 

nothing is passed to the .siblings () function. Cannot read property 'siblings' of undefined

The problem is that I have two inputa with this class. How can I pass to the function information about which particular input has been changed?

  • "// non-working option" - what is it not working? - Igor
  • @Igor does not pass anything to the .siblings () function. Cannot read property 'siblings' of undefined - JamesJGoodwin

1 answer 1

nothing is passed to the .siblings () function. Cannot read property 'siblings' of undefined

Can not be. You call updateIata with an undefined parameter (or without a parameter). Or use it as a callback, where the calling code does not send anything.

  • Yes exactly. All from inattention :( - JamesJGoodwin