How do I delay animation with jQuery?
I need to get a navigation to expand the width, and then expand the height, and then reversed for the reverse animation.
Code:
$(function() {
$("#nav li").not("#logo, #nav li ul li").hover(function(){
$(this).animate({width:"200px"},{queue:false,duration:1000});
}, function(){
$(this).animate({width:"30px"},{queue:false,duration:1000});
});
$("#nav li.parent").hover(function(){
$(this).children("ul").animate({height:"40px"},{queue:false,duration:500});
}, function(){
$(this).children("ul").animate({height:"0px"},{queue:false,duration:500});
});
});
use the jQuery .delay(N)
methods, where N is the milliseconds to delay.
jsFiddle example
Here is the call you are looking for http://api.jquery.com/delay/
.delay(n) // where n is the millis of delay
use is as follows
$.animate(action1).delay(n).animate(action2)
// this code puts the delay bewtween two different animations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With