jQuery click event handler doesn’t work – use live :)
If you are trying to use jQuery .click() event handling on dynamically added elements/controls, you might notice something that looks like click event never getting fired. This happens because click handler gets set on current set of elements only. For dynamic elements you have to use something that handles future elements as well.
When I saw it first time, I thought I found a bug in either jQuery or browser or both. Anyways, this particular case is not a bug.
Answer is using .live().
Example:
$("#ID").live("click", function() {
// Handler code
});
Advertisement
I simply want to tell you that I am newbie to weblog and actually savored this website. Almost certainly I’m going to bookmark your site . You amazingly have really good articles. Bless you for sharing with us your website.
Specialized niche web directories are still important as ever before .