Smarter Event Binding

Avatar of Chris Coyier
Chris Coyier on
$("p").live("click", function(){
      $(this).css("color", "red");
});

The reason this is smarter is because there are likely many p elements on the page. If there were, say, 10 of them, traditional click event binding would require 10 handlers. The live function only requires one, reducing memory needed by the browser. Then imagine compounding the issue by 100 (for example, a table with 1000 cells with hover events).

Additionally, using the live function does not require events to be re-bound when additional elements are added to the page (like via AJAX).