0

So, I've got this:

$('header').fadeIn(1000, function() {
    // Animation complete
});

$('#intro').fadeIn(3000, function() {
    // Animation complete
});

And now I want the second one to come in later, so with a delay. But where in the code do I put this?

EDIT: Got it, thanks!

Luc
  • 1,765
  • 5
  • 24
  • 44
  • What do you mean by delay? After the first one has finished fading in or just a certain amount of seconds? – tpbowden Apr 11 '13 at 09:56
  • After the first one has completed fading in, then the second one has to start. – Luc Apr 11 '13 at 10:16

2 Answers2

1

If you want to start the second animation after the first one, you should do this

$('header').fadeIn(1000, function() {
    $('#intro').fadeIn(3000, function() {
    // Animation complete
   });
});
Thomas Ledan
  • 118
  • 11
1

jQuery maintains a queue of effects per element. You are animating 2 elements so they will fire simultaneously.

More info: http://api.jquery.com/queue/

You can nest the functions but that's going to get difficult if you want 10 effects.

Here's a good solution:

https://stackoverflow.com/a/11354378/907253

Community
  • 1
  • 1
StarQuake
  • 147
  • 1
  • 2
  • 11
  • Hm, they still fire simultaneously. What does the 'my-queue' for? mustn't I define it somewhere? – Luc Apr 11 '13 at 10:13