I excavated this thread: JQuery live or something similar with .change()?
I have exactly the same problem as the person in that thread. I need to call change() on elements appended() in DOM.
I had success in using .live() but for clicks. Now I need to do the same things for the change in drop down list selection.
Ideally I don't want to use any plugins, as suggested in the topic.
Does anyone has any ideas how to solve the problem?
As of jQuery 1.7, $.live() is deprecated. You should use the new $.on() method:
$("form").on("change", "select", function(){
alert ( this.value );
});
Demo: http://jsbin.com/ahikov/edit#javascript,html
Use .on() with the "delegated" syntax.
$(function ()
{
$(document).on('change', 'select', function ()
{
// your event handling code here
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With