jquery悬停问题
有时,当我将鼠标快速移动到链接上时,我会遇到鼠标悬停问题,它会循环很长一段时间,有没有一种方法可以仅在鼠标仍然悬停时循环,如果鼠标不在则停止。
$('ul.display li').hover(function() {
$('ul.display li').find('#details').hide(); // hides all deatils div before showing
$('#light').delay('800').fadeIn("fast"); // shows div that fades out all other content.
if($.cookie("switch_thumb") =="thumb_view" || $.cookie("switch_thumb") =="null"){//checks for cookie set for display type
$(this).find('#details').delay('900').animate({width:'toggle'}); // grow width
}else{
$(this).find('#details').delay('900').animate({height:'toggle'}); // grow height
}
}, function() {
$('#light').fadeOut("fast"); // dim the light to show all content
$('ul.display li').find('#details').hide(); //hide all details
return false; // supposed to stop looping.
});
i have mouseover issues sometimes when i move my mouse fast over links it loops for quite a while, is there a way to only loop if mouse is stil over and stop if the mouse is not.
$('ul.display li').hover(function() {
$('ul.display li').find('#details').hide(); // hides all deatils div before showing
$('#light').delay('800').fadeIn("fast"); // shows div that fades out all other content.
if($.cookie("switch_thumb") =="thumb_view" || $.cookie("switch_thumb") =="null"){//checks for cookie set for display type
$(this).find('#details').delay('900').animate({width:'toggle'}); // grow width
}else{
$(this).find('#details').delay('900').animate({height:'toggle'}); // grow height
}
}, function() {
$('#light').fadeOut("fast"); // dim the light to show all content
$('ul.display li').find('#details').hide(); //hide all details
return false; // supposed to stop looping.
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我曾经遇到过类似的问题。 stop() 也可以工作,但我所做的是在开始淡入淡出时向元素添加一个“inmotion”类,并在淡入淡出完成时将其删除。通过在该标签打开时忽略任何悬停调用,它确保每个操作都必须在下一个操作开始之前完成。
I had a similar problem once. stop() can work too, but what I did was to add a class "inmotion" to the element when starting a fade, and remove it when the fade was complete. By ignoring any hover calls when that tag was on, it made sure every action had to finish before the next could begin.
查看
.stop()
方法Check out
.stop()
method