jquery - Mulitlpe dropdowns with hidden textfields -


i'm trying have text field show when select "other" drop down. works fine, on first instance. need work on multiple occasions per page. have tried .each(), .foreach() can't seem find right place it. how function on multiple dropdowns

js:

    $(window).load(function(){     $('#myselect').change(function() {         if($(this).val() == 2)             $('#txtdata').show();         else             $('#txtdata').hide();     });     }  ) 

html:

<select id="myselect">        <option value="" selected="selected">-select one-</option>      <option value="no">no</option>      <option value="2">yes</option>  </select> <br /> <input type="text" id="txtdata" placeholder="please specify..." class="other" style="display:none;"  /> 

i'm not sure trying see if helps you:

jsfiddle demo change()

i switched code use class , not id's , created several input text each selectbox.

otherwise try being more specific please.

code:

$('.other').hide();  $('.sectos').change(function() {     if($(this).val() == 3){        $(this).next('input').fadein();      }     else{        $(this).next('input').fadeout();             } }); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -