【发布时间】:2010-11-07 21:59:10
【问题描述】:
我使用 JQuery 完成了一个小型动画工作:一张表 #photos 包含 9 张照片,我想在鼠标悬停时使用 animate 函数增加宽度和高度。但是,如果用户将鼠标移到另一张照片上,则动画正在运行时,它会自动触发下一个动画,因此完全混乱。我该怎么办?我的代码是:
$(function(){
$("#photos tr td img").mouseover(function(){
$(this).animate({"width":"1000px","height":"512px"},2000)
});
$("#photos tr td img").mouseout(function(){
$(this).animate({"width":"100px","height":"50px"},2000)
});
});
【问题讨论】:
-
提示:使用悬停功能代替 mouseover 和 mouseout。 docs.jquery.com/Events/hover
标签: jquery animation jquery-animate