2010-08-06 63 views
1

如果我將鼠標懸停在超鏈接上,我寫了jquery代碼來顯示說明。但我不知道如何控制懸停的速度,以便我可以緩慢地顯示描述。任何人都可以請建議我如何做到這一點。在jquery中控制懸停速度

感謝

+0

你使用哪種動畫方法? – Sarfraz 2010-08-06 13:28:33

回答

1

您可以使用.fadeIn()/.fadeOut().animate({ opacity: 'toggle' }),例如:

$(".class").hover(function() { 
    $(this).next('.description').fadeIn(); //or .fadeIn(2000) for 2 seconds 
}, function() { 
    $(this).next('.description').fadeOut(); 
}); 

You can give it a try here,或較短.animate()版本:

$(".class").hover(function() { 
    $(this).next('.description').animate({ opacity: 'toggle' }) 
}); 

You can try that here,在上面的代碼你可以添加一個持續時間作爲其中任何一個參數的下一個參數它默認是400ms。

+0

非常感謝。它爲我工作。 – user346514 2010-08-10 20:17:56