【问题标题】:jQuery fadeIn and fadeOut on hover freeze after using .stop()使用 .stop() 后悬停冻结时的 jQuery 淡入和淡出
【发布时间】:2010-12-08 04:28:00
【问题描述】:

我有一个简单的悬停淡入淡出和淡入淡出,您将在我的代码中看到。问题是,为了防止淡入/淡出发生 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);
});

【问题讨论】:

  • 与其提供代码,请您描述一下您想要完成的任务吗?

标签: javascript jquery hover fadein fadeout


【解决方案1】:
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

【讨论】:

  • 你是绝对正确的,这就像一个魅力。现在只有当我能找到一种方法来为 slideUp 和 slideDown 效果做同样的事情时:(
  • 您可以使用可以移动对象的动画功能。我没有头脑中的代码,但请看这里api.jquery.com/animate
【解决方案2】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 2011-01-25
    相关资源
    最近更新 更多