Example 1 — Official Start/Stop Demo
From the jQuery docs: build a long chain, then clear pending steps and stop the current effect.
$("#start").on("click", function () {
var myDiv = $("div.box");
myDiv.show("slow");
myDiv.animate({ left: "+=200" }, 5000);
myDiv.queue(function () {
$(this).addClass("newcolor").dequeue();
});
myDiv.animate({ left: "-=200" }, 1500);
myDiv.queue(function () {
$(this).removeClass("newcolor").dequeue();
});
myDiv.slideUp();
});
$("#stop").on("click", function () {
var myDiv = $("div.box");
myDiv.clearQueue();
myDiv.stop();
}); How It Works
- Start. Several effects and
.queue()callbacks are chained ontofx. - Waiting. Only one step runs at a time; the rest sit pending.
- clearQueue. Removes every function that has not started.

