javascript - JQuery onchange works multiple times in jsfiddle but only once in browser -


i have added jquery (1.11.1) script business catalyst site cart page hide or display message depending on dropdown user clicks. works multiple times in jsfiddle http://jsfiddle.net/nathanhill/462tk/ once in browser. javascript placed in line after drop down.

i not have control on html dropdown cannot insert function html onchange.

html:

<select onchange="somebcfunction(a,b,c);" id="shippingcountry">     <option value="af">afghanistan</option>     <option value="ax">aland islands</option>     <option value="gb" selected="selected">united kingdom</option> </select>  <div id="zones">show message</div> 

javascript:

<script type="text/javascript">     $(document).ready(function(){         $('#shippingcountry').on('change', function() {             if ( this.value == 'gb')             {                 $("#zones").show();             }             else             {                 $("#zones").hide();             }         });     }); </script> 

any appreciated.

i tried add/append existing bc function triggered eg:

var somebcfunction = oldbcfunction  function somebcfunction (){  //my hide-display code  oldbcfunction;  }  

but got this...

it works fine on chrome version 35.0.1916.153 m.

ps. removed onchange="somebcfunction(a,b,c);" browser dosen't , error each time change selected item, but onchange works multiple times, althougth if not used should remove it.

<head>     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </head> <div class='required'>     <select id="shippingcountry">          <option value="af">afghanistan</option>         <option value="ax">aland islands</option>         <option value="gb" selected="selected">united kingdom</option>        </select>     <div id="zones">show message</div> </div> <script type='text/javascript'>  $(document).ready(function(){       $('#shippingcountry').on('change', function() {       if ( this.value == 'gb')       {         $("#zones").show();       }       else       {         $("#zones").hide();       }     });   }); </script> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -