Delaying Animation

$("img").animate({width:500},   1000).delay(2000).animate({     opacity:1} 1000);

A great option when implementing animations is adding a delay before the animation is added to the queue. You can use this to provide animations in a more advanced way because you delay the execution of the animation queue, giving the user a better visual experience.

The .delay(duration, [, queueName]) method allows you to specify the delay duration in milliseconds as well as an optional queueName that specifies which queue to apply the delay to. For example, the following code adds a size animation to images. Once the size is complete, there is a delay of 2 seconds, and the opacity animates up to 1:

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.