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(); 

working demo


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -