Possible Duplicate:
jQuery 1.7 – Turning live() into on()
I used to love the .live() function that jQuery had. You would add it and voila, any future elements that matched the identifier would have that function.
Then it got deprecated and it was advised to use .on(). But it doesn’t work. Below is my code that is placed in $(document).ready().
This works
$('#membership_number').live('change',function(e) {
alert("VALUE CHANGED");
});
This doesn’t
$('#membership_number').on('change',function(e) {
alert("VALUE CHANGED");
});
Is there another way to achieve the same effect as .live() or am I just not using .on() correctly?
You have to subscripe the event to parent item and give selector to which you want to bind. If you do not want to give parent you can use document. Read more about on here
OR