您可以使用setTimeout進行此操作,並與元素的存儲「懸停狀態」進行比較。 如果您使用多個單元格,我的示例可能不是存儲懸停狀態的最佳方式,但該概念依然存在。
var TIME_UNTIL_SLIDE = 1000;
var isHovering = false;
var hovertimer;
$('.smallCell.slidedown').hover(function() {
isHovering = true;
var $this = this;
hovertimer = setTimeout(function(){
if(isHovering) {
$(".overlay", $this).stop().animate({
top: '-260px'
}, {
queue: false,
duration: 300
});
}
}, TIME_UNTIL_SLIDE);
}, function() {
isHovering = false;
$(".overlay", this).stop().animate({
top: '0px'
}, {
queue: false,
duration: 300
});
});
顯示在: http://jsfiddle.net/fvXgK/16/
來源
2012-07-24 16:15:35
Ben
這任何對你有好處? http://www.jquery4u.com/events/writing-mousestop-event-plugin-jquery/#.UA7GO6AcvAk – 2012-07-24 16:04:05