Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个代码,jquery 在哪里寻找,鼠标在哪里(悬停/鼠标悬停)
$(".hover tr").live("mouseleave",function(){ $(this).find("td:last-child").html(" "); });
由于某种原因,这不起作用:(
您需要在代码的开头输入 jquery 脚本。
试试这个例子:
<script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"></script>
把它放在<head>标签里面
<head>
这可能是因为live()从 1.9 开始已从 jQuery 中删除(并从 1.7 弃用);相反,您应该使用以下on()方法:
live()
on()
$('.hover tr').on('mouseleave', function(){ // do stuff });
当然,这个答案假设您使用的是 jQuery 的最新版本。
参考:
从 jQuery 1.7 开始,不推荐使用 .live() 方法。用于.on()附加事件处理程序。旧版本 jQuery 的用户应该.delegate()优先使用.live().
.on()
.delegate()
.live()
来源http://api.jquery.com/live
阅读http://api.jquery.com/on