Last active
December 14, 2015 21:59
-
-
Save bittersweetryan/5154945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var div = $( '#doStuff' ); | |
//add the delay to the queue | |
div.delay( 1000, 'myQ') | |
.queue( 'myQ', function(){ | |
//this still refers to the current element | |
$( this ).prepend( '<p>Waited 1 second</p>' ) | |
.find('p') | |
.fadeIn() | |
//invoke the next element in the queue | |
.end().dequeue( 'myQ' ); | |
} ) | |
.delay( 500, 'myQ' ) | |
.queue( 'myQ', function(){ | |
$( this ).prepend( '<p>Waited .5 more seconds</p>' ) | |
.find('p') | |
.fadeIn() | |
.end().dequeue( 'myQ' ); | |
} ) | |
.delay( 1000, 'myQ') | |
.queue( 'myQ', function(){ | |
$( this ).prepend( '<p>Waited 1 more seconds</p>' ) | |
.find('p') | |
.fadeIn(); | |
}); | |
//start removing items from the queue | |
div.dequeue( 'myQ' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment