jquery - Hide and show is not working -


i have problem jq script , cannot find bug. when select yes option selection box website should display "type email address" , hide "type new username". here's code:

<html> <head>  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">  </script>    <script> $(function () { $('#am').on('change', function () {      var stringt = $('#am :selected').val();      if (stringt === "yes") {         $("#campos1").hide();         $("#campos2").show();     } else {         $("#campos1").show();         $("#campos2").hide();     }   }); }); </script>  </head> <html>    <li>are member?     <select name="am">       <option value="1" selected="selected">yes</option>       <option value="2">no</option>     </select>    </li>  <div id="campos1">    <li>type email address.     <input id="field5" name="institucion_1" type="text" />    </li>  </div>  <div id="campos2">    <li>type new username.     <input type="text" />    </li>  </div>  </html> 

here's jsfiddle: http://jsfiddle.net/sushanth009/cccbq/5/ feel free modify , suggest me comments. :)

you're trying select element id has none name give id can select id, values of select 1 , 2 not yes , no

<select name="am" id="am">  ... if (stringt === "1") { 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -