Use dequeue to end a custom queue function which allows the queue to keep going.
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function () {
$("div").animate({left:'+=210px'}, 2000);
$("div").animate({top:'1000px'}, 1200);
$("div").animate({top:'10px'}, 1200);
$("div").animate({top:'1000px'}, 1200);
$("div").queue(function () {
$(this).toggleClass("red");
$(this).dequeue();
});
$("div").animate({left:'120px', top:'30px'}, 700);
});
});
</script>
<style>
div { margin:3px; width:50px; position:absolute;
height:50px; left:10px; top:30px;
background-color:yellow; }
div.red { background-color:red; }
</style>
</head>
<body>
<body>
<button>Start</button>
<div>adsf</div>
</body>
</html>
Related examples in the same category