How to use jQuery on() and off() method


Using jQuery .on() and .off() – AndiSmith.com

jQuery 1.7 was released in month of November last year and with the jQuery 1.7, do you know that live() method is deprecated. And new method was introduced to replace live() called "on()". "jQuery on()" is a new way to attach events to selectors. The on() event handler is designed to replace both the .bind() and .delegate() event handlers.

I have found an article with the explanation of these new functions. Along with explanation, it also throws light on some other aspects to the changes in jQuery 1.7+ that one should keep in mind.

Also read, "bind() vs live() vs delegate() method"

Why live was deprecated()

There are a number of problems with .live(), especially with poor performance on large pages, a slower response or unexpected behaviour due to .live() events being attached to the document element. Unfortunately there are still a large number of developers using .live() in their code. If you’re one of them, please stop. See "Why .live() is a Bad Option" for more information.

Feel free to contact me for any help related to jQuery, I will gladly help you.



Responsive Menu
Add more content here...