Unterschiede zwischen .bind(), .live(), and .delegate()

Steve Schwartz erklärt die Unterschiede zwischen den jQuery Methoden .bind(), .live(), und .delegate()

jQuery’s delegate method is generally preferred to the live method for a few reasons. Consider the following examples:

$('a').live('click', function() { blah() });
// or
$(document).delegate('a', 'click', function() { blah() });

The latter is actually faster than the former, because the former first scans the entire document for all $(‘a’) elements, storing them as jQuery objects. (…) the live method has a very large shortcoming, and that is that it can only operate on a direct CSS selector string. This makes it very inflexible.

Possibly related posts (automatically generated)