Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Binding Live Events in jQuery

Dynamically created DOM elements in Javascript are do not by default have event Listeners bound to them. In order to have this automatically happen use the “live” method in Jquery. This method monitors the changes to the DOM and updates the listener. It is much more efficient code than Binding listeners after element creation. Below is a quick example of a live click binding:

$(".class").live('click', function(event){
  event.preventDefault();
});


This post first appeared on Nick Holdren, please read the originial post: here

Share the post

Binding Live Events in jQuery

×

Subscribe to Nick Holdren

Get updates delivered right to your inbox!

Thank you for your subscription

×