Why does the "complete" callback for the third animation happen first, before any animations have started?
Script:
$( "#animate" ).delay(2000).animate(
{ "width": "500px" },
{ "duration": 3000,
"complete": function(){ $( "#animate" ).append( "1st<br />" ); }}
)
.delay(1000).animate(
{ "width": "200px" },
{ "duration": 3000,
"complete": function(){ complete( "2nd" ); }}
)
.delay(1000).animate(
{ "width": "500px" },
{ "duration": 3000,
"complete": complete( "3rd" ) }
);
function complete( ordinal ){
$( "#animate" ).append( ordinal + "<br />" );
};
HTML:
<div id="animate" />
CSS:
#animate
{
border: 1px solid red;
height: 200px;
width: 200px;
}
jsfiddle: