mmcglynn
mmcglynn

Reputation: 7672

Delay the jQuery animation

How do I delay the jQuery animation on my page until all CSS images are loaded?

Upvotes: 1

Views: 276

Answers (2)

Nick Craver
Nick Craver

Reputation: 630627

Use the window.onload event instead of document.ready via .load(), like this:

$(window).load(function() {
  //animate things
});

The main difference here is that images are loaded, where they may or may not be on ready, since it's looking to see that the DOM is loaded, not necessarily extra content in it, like images.

Upvotes: 4

jAndy
jAndy

Reputation: 236192

use the onload event.

$(window).bind('load', function() {
   // do the animation
});

Upvotes: 2

Related Questions