jQuery from ‘live’ to ‘on’

jQuery’s live event handler is deprecated (as of version 1.7) and no longer supported (as of version 1.9). The new event handler is called on. Here’s how to migrate your scripts.

Before:

1
2
3
$(".my_selector").live("click", function(e) {
    // ...
});

Now:

1
2
3
$(document).on("click", ".my_selector", function(e) {
    // ...
});

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>