0 votes
in JQuery by
What is the difference between bind() vs live() vs delegate() methods in jQuery?

1 Answer

0 votes
by

bind(): this method registers the event handler directly to the required DOM element. E.g.:

$(“#members a”).bind(“click”, function(f){….});

This means any matching anchors will have this event handler attached!

live(): this method attaches the event handler to the root of the document. This means one handler can be used for all events that propagated to the root. The handler is thus attached only once.

delegate(): in this method, you can choose where to attach the handler. This is the most efficient and robust method for delegation.

E.g.:

$(“#members”).delegate(“ul li a”, “click”, function(f){….});

...