jquery - how to use class name generated in while loop -


i want use class name generated in while loop jquery function.

while() { <select class='one'> </select> <select class='two'> </select>   $(function(){  $('.one').on('change',function(){     var selindex= $(".one option:selected").index();      $(".two option").eq(selindex).prop('selected', true); });  }); } 

you need target relative elements, can use this inside event handlers target changed select.one.

$(function () {      $('.one').on('change', function () {         var selindex = $(this).find("option:selected").index();         $(this).next(".two").find('option').eq(selindex).prop('selected', true);     });  }); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -