Object has no method 'live' - jQuery

reggie picture reggie · Jan 25, 2013 · Viewed 52.8k times · Source
<script>
$(document).ready(function(){
    $('.delete').live('click', function(e){
        alert('delete');
        e.preventDefault();
    });
});
</script>
<a href='#' id='_1' class='delete'>Delete</a>

Gives me an error:

Uncaught TypeError: Object [object Object] has no method 'live'

I just don't see the problem?

Answer

diggersworld picture diggersworld · Jan 25, 2013

.live() is a deprecated function (from 1.7+) and removed completely from jQuery 1.9+.

You can instead use .on() or .bind() methods:

http://api.jquery.com/on/
http://api.jquery.com/bind/