Controlling hover speed in jquery
I have written jquery code to show开发者_C百科 description if I hover on a hyperlink. But I donot know how to control the speed of the hover, so that i can show the description slowly.Can anyone please suggest me how to do this.
Thanks
You can use .fadeIn()
/.fadeOut()
or .animate({ opacity: 'toggle' })
, for example:
$(".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, or the shorter .animate()
version:
$(".class").hover(function() {
$(this).next('.description').animate({ opacity: 'toggle' })
});
You can try that here, in the code above you can add a duration as the next parameter to any of these, without it the default is 400ms.
精彩评论