jquery change event not registering for dynamcally added select -


hoping can help, i've got noddy jquery kick off when changes select, follows: -

$(function() {     $("select").change(function() {         var banana = $(this).attr("id");          if((banana.indexof("forms[")>-1)){             var formid= $(this).val();             getforminformation(formid);         }     }); }); 

this works fine selects appear on page when first loaded, however, have jquery in there dynamically add selects page post, , not picking those, ideas?

thanks in advance!

you need attach event handlers dynamically appended elements. using jquery, .on() method attaches event handlers selected set of elements in jquery object. of jquery 1.7, .on() method provides functionality required attaching event handlers.

this might you:

$(document).on('click','select',function(){     alert("click"); }); 

also have @ .on() documentation.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -