The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery – Better understanding of .live(); Re: jQuery – Better understanding of .live();


@senff “on” only needs a different structure of you care what was hovered/clicked on inside of the original selector. If you only care that “.tweet” is hovered on:

$(‘.tweet’).on(‘hover’, function() { // something });

But if you want to know only when anchors on the tweet are hovered on

$(‘.tweet’).on(‘hover’, ‘a’, function() { // something });

“live” used to work by listening to every event all the time, but that was wasteful. It’s better if we can just specify a constant to listen to and evaluate the event for more specific data only when we need to.

That’s what “on” does and that’s why live is deprecated. The jQuery source actually just takes anytime you use “live” and makes it the “on” method.

function (types, data, fn) {
jQuery(this.context).on(types, this.selector, data, fn);
return this;