Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Explain .bind() vs .live() vs .delegate() vs .on()

Answer Posted / chaitanya

All these 4 jQuery methods are used for attaching events to selectors or elements. But they all are different from each other.

.bind(): This is the easiest and quick method to bind events. But the issue with bind() is that it doesn't work for elements added dynamically that matches the same selector. bind() only attach events to the current elements not future element. Above that it also has performance issues when dealing with a large selection.

.live(): This method overcomes the disadvantage of bind(). It works for dynamically added elements or future elements. Because of its poor performance on large pages, this method is deprecated as of jQuery 1.7 and you should stop using it. Chaining is not properly supported using this method.

.delegate(): The .delegate() method behaves in a similar fashion to the .live() method, but instead of attaching the selector/event information to the document, you can choose where it is anchored and it also supports chaining.

.on(): Since live was deprecated with 1.7, so new method was introduced named ".on()". This method provides all the goodness of previous 3 methods and it brings uniformity for attaching event handlers.

Find out more here

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the approaches of extracting a query string with regular expressions?

739


Explain some of the key concepts of good code organization patterns.

806


Create a plugin that would add and remove a class on hover.

769


What is the difference between javascript and jquery?

894


How to resolve conflicts with other libraries?

835


what does $("div") will select? : jquery mobile

806


Tell me how to disable jquery animation? : jquery mobile

739


How do you get the text value of a selected option?

740


Explain width() vs css(‘width’)?

746


What features of jquery, has been used in web applications?

779


How to revert the most recent ‘destructive’ operation, changing the set of matched elements to its previous state using ?

791


what are the features of jquery

795


Does jquery 2.0 supports ie? : jquery mobile

798


Can you please explain the difference between javascript and jquery? : jquery mobile

770


What is a cdn? : jQuery Mobile

848