对象没有'live'方法 - jQuery [英] Object has no method 'live' - jQuery

查看:155
本文介绍了对象没有'live'方法 - jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script>
$(document).ready(function(){
    $('.delete').live('click', function(e){
        alert('delete');
        e.preventDefault();
    });
});
</script>
<a href='#' id='_1' class='delete'>Delete</a>

给我一​​个错误:


未捕获TypeError:对象[object Object]没有方法'live'

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

我只是看不到问题?

推荐答案

.live()是一个不推荐使用的函数(来自1.7+)并完全从jQuery 1.9 +中删除。

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

您可以使用 .on() .bind()方法:

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

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

这篇关于对象没有'live'方法 - jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆