2010-12-08 102 views
2

我有一個簡單的懸停fadeIn和fadeOut,你會在我的代碼中看到。問題是,爲了防止fadeIn/Out發生100次,我必須在調用fadeIn/Out之前使用.stop(),但停止似乎凍結了元素淡入淡出,然後當您將鼠標懸停時,它只會消失在儘量讓你這樣,你可以在這裏看到一個例子:http://ena.vu/jhover/jhover.htmljQuery淡入淡出使用.stop()後懸停凍結()

和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); 
});
+0

而不是提供代碼,請您描述一下您想要完成的任務嗎? – Matrym 2010-12-08 05:03:52

回答

3
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

+0

你是絕對正確的,這就像一個魅力。現在只有當我能找到一種方式來做同樣的slideUp和slideDown的效果:( – agrublev 2010-12-08 19:09:21

0

你可以利用這一點,它可能對你有所幫助

OBJ。 children()。mouseover(function(){ $(this).find(「。」+ options.title_class).stop()。fadeTo('fast',1).show();()。().find(「。」+ options.title_class).stop()。fadeOut('fast'); });

+0

對不起,你的代碼使事情變得最糟:( – agrublev 2010-12-08 04:57:27