使用 .stop() 后悬停冻结时的 jQuery fadeIn 和 fadeOut

发布于 2024-10-06 09:56:22 字数 480 浏览 0 评论 0原文

我有一个简单的悬停淡入和淡出,正如您将在我的代码中看到的那样。问题是,为了防止淡入/淡出发生 100 次,我必须在调用淡入/淡出之前使用 .stop() ,但是停止似乎会冻结元素淡入淡出,然后当您将鼠标悬停在它上面时只会淡出只要你允许,你可以在这里看到一个例子: http://ena.vu/jhover/ jhover.html

和 jQ 代码是:


obj.children().hover(function(e){ 
$(this).find("."+options.title_class).stop().fadeIn(options.title_speed);
},function(){
$(this).find("."+options.title_class).stop().fadeOut(options.title_speed);
});

I have a simple hover fadeIn and fadeOut as you will see in my code. The problem is that to prevent the fadeIn/Out from happening a 100 times i have to use .stop() before i call fadeIn/Out, but the stop seems to freeze the elements fade and then when you hover back over it will only fade in as far as you let it, you can see an example here: http://ena.vu/jhover/jhover.html

and the jQ code is:


obj.children().hover(function(e){ 
$(this).find("."+options.title_class).stop().fadeIn(options.title_speed);
},function(){
$(this).find("."+options.title_class).stop().fadeOut(options.title_speed);
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

染墨丶若流云 2024-10-13 09:56:22
obj.children().hover(function(e){  
$(this).find("."+options.title_class).stop().fadeTo(options.title_speed,1); 
},function(){ 
$(this).find("."+options.title_class).stop().fadeTo(options.title_speed,0); 
});

我相信这对你有用。
了解更多关于 fadeTo

obj.children().hover(function(e){  
$(this).find("."+options.title_class).stop().fadeTo(options.title_speed,1); 
},function(){ 
$(this).find("."+options.title_class).stop().fadeTo(options.title_speed,0); 
});

I am sure this will work for you.
Read more on fadeTo

枕头说它不想醒 2024-10-13 09:56:22

你可以使用这个,它可能对你有帮助

obj.children().mouseover(function(){
$(this).find("."+options.title_class).stop().fadeTo('fast', 1).show();

}).mouseout(函数(){
$(this).find("."+options.title_class).stop().fadeOut('fast');
});

You can use this,it may helpful to you

obj.children().mouseover(function(){
$(this).find("."+options.title_class).stop().fadeTo('fast', 1).show();

}).mouseout(function(){
$(this).find("."+options.title_class).stop().fadeOut('fast');
});

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文