jquery - Show Nth span based on Nth list option selected -
i have table select list in each row. adjacent select list spans, need showing corresponding option selected, provide explanation chosen option.
for example:
in each row if user selects 1st option show 1st span
this logic should apply whole table. have js fiddle here, cannot index value each option.
you not need 2 separate event this. can use single event select , traversing target , show desired element:
$("select").change(function(){ $(this).parent().next().find('span').hide(); $(this).parent().next().find('span').eq($(this).find('option:selected').index()).show(); }).change();
Comments
Post a Comment