I've read some posts here and elsewhere on the web about the differences between live()
and delegate()
. However I haven't found the answer I'm looking for (if this is a dupe please tell me).
I know that the difference between live
and delegate
is that live
cannot be used in a chain. I also read somewhere that delegate
is in some cases faster (better performance).
My question is, is there a situation where you should use live
instead of delegate
?
UPDATE
I've set up a simple test to see the difference in performance.
I've also added the new .on()
which is available in jQuery 1.7+
The results pretty much sum up the performance issues as stated in the answers.
- Don't use
.live()
unless your jQuery version doesn't support.delegate()
. - Don't use
.delegate()
unless your jQuery version doesn't support.on()
.
The difference between .live()
and .delegate()
is A LOT bigger than between delegate()
and .on()
.