2010-08-06 57 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