Moving from jquery live

everyone talks about getting out of life and using a delegate. Here is my live code.

$('a').live('click', function(){})

And here the code is converted using a delegate.

$('body').delegate('a', 'click', function(){})

This change seems to work. However, I do not have any tests and just want the community to confirm that such a change is in order, and I can continue.

+3
source share
1 answer

Check out the following link:

Why you should not use jQuery Live

In addition, I think these two equivalents:

$('body a').live('click', function(){})
$('body').delegate('a', 'click', function(){})
+4
source

All Articles