I see there's a new method .on()
in jQuery 1.7 that replaces the .live()
in earlier versions.
I'm interested to know the difference between them and what the benefits are of using this new method.
I see there's a new method .on()
in jQuery 1.7 that replaces the .live()
in earlier versions.
I'm interested to know the difference between them and what the benefits are of using this new method.
I am the author of a Chrome extension "Comment Save" which uses jQuery, and one which used
.live()
. The way the extension works is by attaching a listener to all the textareas using .live()
- this worked well since whenever the document changed it would still attach the listener to all the new textareas.I moved to
.on()
but it doesn't work as well. It doesn't attach the listener whenever the document changes - so I have reverted back to using.live()
. That is a bug I guess in.on()
. Just be careful about it I guess.Good tutorial on difference between on vs live
Quote from the above link