jQuery attach click event on empty select box -


using jquery, how load select box options dynamically while clicking on select box.

i using redmine rest api's load issue categories dynamically in select box.

how attach event handler selectbox.

but not working, i.e event not attaching

<script>     //dynamically load status values     $('#newstatusfield').on('click',function(){              alert('inside');     }); </script> <select name="status" id="newstatusfield" data-mini="true" data-native-menu="false">  <!--dynamic option values --> </select> 

always try wrap jquery code inside document.ready fucntion , change event work :

edit : include latest jquery library can download here jquery library

<head>  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>  <script>      $(document).ready(function()     {           $('#newstatusfield').on('change',function(){                  alert('inside');          });      });      </script>  </head> 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -