$(function(){
$("#top-img").hover(function(){
$(this).stop().animate({height:"400px"},{queue:false,duration:700});
},
function() {
$(this).stop().animate({height:"300px"},{queue:false,duration:700});
});
});
这是我正在使用的代码,大部分都很简单。当我将鼠标悬停在 div #top-img
上时它从 300px
的高度(在 CSS 中设置)获取它。并将其动画到高度 400px
.
我想要稍微延迟一下,以便
- 人们必须将鼠标悬停在它上面一秒钟,然后它才会运行
- 在它返回之前,你必须离开它一秒钟
300px
.
最佳答案
查看 HoverIntent jQuery 插件。我过去使用过它,它非常易于使用和实现
关于hover - 当鼠标悬停在高度变化时如何添加延迟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13465825/