2010-09-16 17:13:38 +00:00
<!DOCTYPE html>
2010-11-02 01:46:29 +00:00
< html lang = 'en' > < head >
2011-02-18 20:00:18 +00:00
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, minimum-scale=1, maximum-scale=1" > < meta http-equiv = 'content-type' content = 'text/html; charset=UTF-8' / > < / head > < body >
2010-09-18 16:20:35 +00:00
< div data-role = "page" >
2010-09-21 14:58:54 +00:00
< div data-role = "header" >
2010-09-16 17:13:38 +00:00
< h1 > .clearQueue()< / h1 >
< / div >
2010-10-12 19:50:28 +00:00
< div data-role = "content" data-theme = "c" id = "clearQueue1" >
2010-09-16 17:13:38 +00:00
< h2 class = "jq-clearfix roundTop section-title" >
< span class = "name" > .clearQueue( [ queueName ] )< / span > < span class = "returns" > Returns: < a class = "return" href = "http://docs.jquery.com/Types#jQuery" > jQuery< / a > < / span >
< / h2 >
< div class = " entry-details" >
< p class = "desc" > < strong > Description: < / strong > Remove from the queue all items that have not yet been run.< / p >
< ul class = "signatures" > < li class = "signature" id = "clearQueue-queueName" >
< h4 class = "name" >
< span class = "versionAdded" > version added: < a href = "/category/version/1.4/" > 1.4< / a > < / span > .clearQueue( [ queueName ] )< / h4 >
< p class = "arguement" > < strong > queueName< / strong > A string containing the name of the queue. Defaults to < code > fx< / code > , the standard effects queue.< / p >
< / li > < / ul >
< div class = "longdesc" > < p > When the < code > .clearQueue()< / code > method is called, all functions on the queue that have not been executed are removed from the queue. When used without an argument, < code > .clearQueue()< / code > removes the remaining functions from < code > fx< / code > , the standard effects queue. In this way it is similar to < code > .stop(true)< / code > . However, while the < code > .stop()< / code > method is meant to be used only with animations, < code > .clearQueue()< / code > can also be used to remove any function that has been added to a generic jQuery queue with the < code > .queue()< / code > method. < / p > < / div >
< h3 > Example:< / h3 >
< div id = "entry-examples" class = "entry-examples" > < div id = "example-0" >
< h4 > < span class = "desc" > Empty the queue.< / span > < / h4 >
< pre > < code class = "example demo-code" > < !DOCTYPE html>
< html>
< head>
< style>
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
< /style>
< script src="http://code.jquery.com/jquery-latest.js"> < /script>
< /head>
< body>
< button id="start"> Start< /button>
< button id="stop"> Stop< /button>
< div> < /div>
< script> $("#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").clearQueue();
$("div").stop();
});< /script>
< /body>
< /html> < / code > < / pre >
< h4 > Demo:< / h4 >
< div class = "demo code-demo" > < / div >
< / div > < / div >
< / div >
< / div >
< / div >
< / body > < / html >