What’s wrong with the jQuery live method?

See some of the explanations here:

http://www.ultimatewebtips.com/why-jquery-live-is-a-bad-option-to-use/ (Site appears to be down)

Quote:

  1. You can’t use .live() for reusable widgets.

  2. .stopPropagation() doesn’t work with live.

  3. .live() is slower.

  4. .live() is not chainable.

Further beauty of .on() is that it streamlines all events quite well: http://api.jquery.com/on/

D’uh you know about the api link and see how .on() works 🙂

Quote:

The .on() method attaches event handlers to the currently selected set
of elements in the jQuery object. As of jQuery 1.7, the .on() method
provides all functionality required for attaching event handlers. For
help in converting from older jQuery event methods, see .bind(),
.delegate(), and .live(). To remove events bound with .on(), see
.off(). To attach an event that runs only once and then removes
itself, see .one()

Leave a Comment