-
queue( ) returns Array<Function>
Returns a reference to the first element's queue (which is an array of functions).
Example:
Show the length of the queue.
$("#show").click(function () { var n = $("div").queue("fx"); $("span").text("Queue length is: " + n.length); }); function runIt() { $("div").show("slow"); $("div").animate({left:'+=200'},2000); $("div").slideToggle(1000); $("div").slideToggle("fast"); $("div").animate({left:'-=200'},1500); $("div").hide("slow"); $("div").show(1200); $("div").slideUp("normal", runIt); } runIt();HTML:
<button id="show">Show Length of Queue</button> <span></span> <div></div> -
queue( Function callback ) returns jQuery
Adds a new function, to be executed, onto the end of the queue of all matched elements.
Example:
Queue a custom function.
$(document.body).click(function () { $("div").show("slow"); $("div").animate({left:'+=200'},2000); $("div").queue(function () { $(this).addClass("newcolor"); $(this).dequeue(); }); $("div").animate({left:'-=200'},500); $("div").queue(function () { $(this).removeClass("newcolor"); $(this).dequeue(); }); $("div").slideUp(); });HTML:
Click here... <div></div> -
queue( Array<Function> queue ) returns jQuery
Replaces the queue of all matched element with this new queue (the array of functions).
Example:
Set a queue array to delete the queue.
$("#start").click(function () { $("div").show("slow"); $("div").animate({left:'+=200'},5000); $("div").queue(function () { $(this).addClass("newcolor"); $(this).dequeue(); }); $("div").animate({left:'-=200'},1500); $("div").queue(function () { $(this).removeClass("newcolor"); $(this).dequeue(); }); $("div").slideUp(); }); $("#stop").click(function () { $("div").queue("fx", []); $("div").stop(); });HTML:
<button id="start">Start</button> <button id="stop">Stop</button> <div></div>