Skip to content

jQuery v1.9 eliminates $.live() – Use $.on() instead

A past client’s website of mine had several $.live() triggers as that was a great way to attach triggers to future dynamically created objects using jQuery.  However, and we have known that this would be coming, but $.live() has now been depreciated and removed from jQuery with the replacement being $.on().  Any past code referencing $.live() will now stop working if the jQuery library is updated past version 1.9.

An illustration below is how to convert to using $.on():

Where you previously had:
$('.button').live('click', function(){});
Now becomes:
$(document).on('click', '.button', function(){});

Find this useful? Take just a moment and give a $1. Thanks!
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)