gpt4 book ai didi

jquery - 如何防止鼠标快速移动时发生多个事件?

转载 作者:行者123 更新时间:2023-12-01 03:47:21 25 4
gpt4 key购买 nike

当鼠标打开时以及当鼠标离开元素时,我使用此代码在两个图像之间淡入淡出。当鼠标移动太快时,这会产生一些不正确的过渡。如何防止这种情况发生?

我的代码:

$('.prods li').live('mouseenter',function() {
$(this).children('.label').stop().animate({top: '80%',opacity: 1}, 800, 'easeOutQuint');
if ($(this).children('.producthover').length) {
$(this).children('.product').fadeOut(800);
$(this).children('.producthover').fadeIn(800);
}
}).live('mouseleave',function() {
$(this).children('.label').stop().animate({top: '50%',opacity: 0}, 800, 'easeOutQuint');
if ($(this).children('.producthover').length) {
$(this).children('.product').fadeIn(800);
$(this).children('.producthover').fadeOut(800);
}
});

最佳答案

您是否尝试过将 .stop() 更改为 .stop(true,true)

关于jquery - 如何防止鼠标快速移动时发生多个事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12238813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com