I want to know the main difference between
.live() vs. .bind()
methods in jQuery.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The main difference is that
livewill work also for the elements that will be created after the page has been loaded (i.e. by your javascript code), whilebindwill only bind event handlers for currently existing items.Update:
jQuery 1.7 deprecated
live()method and 1.9 has removed it. If you want to achieve the same functionality with 1.9+ you need to use a new methodon()which has slightly different syntax as it’s invoked on document object and the selector is passed as a parameter. Therefor the code from above converted to this new way of binding events will look like this: