I have a jQuery script which is triggered by an onClick event ( through $(“.addContent”).click(function(){ ) and which updates the page, adding an input text tag.
I am subsequently trying to trigger another script using an onChange event ( through $(“.guestInput”).change(function(){ ) on the input text tag which was just added, once the viewer makes a change. It doesn’t work.
I have tried adding the input text tag as static html, and the subsequent onChange event fires successfully, but not when I add the field through jQuery.
Hope this is clear.
Any idea as to what I am doing wrong?
Thanks,
John
You need to use live() for DOM elements added after the initial page load.
so
.click(function() { do_something; });would now be
.live("click", function() { do_something; });see: http://api.jquery.com/live/