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){….});

Related questions

0 votes
asked Nov 20, 2020 in JQuery by sharadyadav1986
0 votes
asked Nov 17, 2020 in JQuery by rajeshsharma
...