jquery:取消fadeto然后取消fadein
我有一个初始显示的div,当鼠标离开div时,它会在10秒内慢慢淡出(使用fadeto)。当鼠标重新进入时,我需要取消fadeto(如果仍在进行中)并将div淡入 我知道(想)停止()是我的救星。它正确地停止了div fadeTo,但为了我的生命,我不能让fadeIn开始 以下是我所拥有的:jquery:取消fadeto然后取消fadein,jquery,fadeto,Jquery,Fadeto,我有一个初始显示的div,当鼠标离开div时,它会在10秒内慢慢淡出(使用fadeto)。当鼠标重新进入时,我需要取消fadeto(如果仍在进行中)并将div淡入 我知道(想)停止()是我的救星。它正确地停止了div fadeTo,但为了我的生命,我不能让fadeIn开始 以下是我所拥有的: $(document).on('mouseenter', '#player', function(){ $(this).stop().fadeIn('fast'); });
$(document).on('mouseenter', '#player', function(){
$(this).stop().fadeIn('fast');
});
$(document).on('mouseleave', '#player', function(){
$(this).stop().fadeTo(10000,0.2);
});
我算出来了
我需要使用fadeTo淡入,而不是fadeIn,因为当使用fadeTo淡出时,它只会调整不透明度,因此仍将其视为可见:
$(document).on('mouseenter', '#player', function(){
$(this).stop().fadeTo('fast',1);
});
$(document).on('mouseleave', '#player', function(){
$(this).stop().fadeTo(10000,0.2);
});