Skip to content

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

This content will be shown before all post

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(){});

This content will be shown after all post