panthro
panthro

Reputation: 24059

How do you delay animations with .animate?

I'm hacking up a fix for jQuery slide down which jumps.

So far I have:

 $div.hide().css({ height : 0 });
 $div.show().animate({ height : height }, { duration: 1000 });

But I want to delay the showing of the div by 1 second. I've tried .delay(1000) but it doesn't work.

Upvotes: 0

Views: 27

Answers (2)

Code Whisperer
Code Whisperer

Reputation: 23652

Fairly simple to execute.

$div.hide().css({ height : 0 });
 setTimeout(function() {
 $div.show().animate({ height : height }, { duration: 1000 }), 1000)
};

Upvotes: 1

Adil Shaikh
Adil Shaikh

Reputation: 44740

You can use setTimeout

setTimeout(function(){
  $div.show().animate({ height : height }, { duration: 1000 });
},1000);  // 1 second delay

Upvotes: 1

Related Questions