forked from jquery/api.jquery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclearQueue.xml
57 lines (53 loc) · 2.03 KB
/
clearQueue.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?xml version="1.0"?>
<entry type="method" name="clearQueue" return="jQuery">
<title>.clearQueue()</title>
<signature>
<added>1.4</added>
<argument name="queueName" optional="true" type="String">
<desc>A string containing the name of the queue. Defaults to <code>fx</code>, the standard effects queue.</desc>
</argument>
</signature>
<desc>Remove from the queue all items that have not yet been run.</desc>
<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>
</longdesc>
<example>
<desc>Empty the queue.</desc>
<code><![CDATA[
$("#start").click(function () {
var myDiv = $("div");
myDiv.show("slow");
myDiv.animate({left:'+=200'},5000);
myDiv.queue(function () {
var _this = $(this);
_this.addClass("newcolor");
_this.dequeue();
});
myDiv.animate({left:'-=200'},1500);
myDiv.queue(function () {
var _this = $(this);
_this.removeClass("newcolor");
_this.dequeue();
});
myDiv.slideUp();
});
$("#stop").click(function () {
var myDiv = $("div");
myDiv.clearQueue();
myDiv.stop();
});]]></code>
<css><![CDATA[
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
]]></css>
<html><![CDATA[<button id="start">Start</button>
<button id="stop">Stop</button>
<div></div>]]></html>
</example>
<category slug="effects/custom-effects"/>
<category slug="data"/>
<category slug="utilities"/>
<category slug="version/1.4"/>
</entry>