jquery dequeue() method
Translation results:
dequeue
UK [dɪk'ju:] US [dɪk'ju:]
v.Dequeue
jquery dequeue() methodsyntax
Function: The dequeue() method executes the next function in the sequence for the matching element.
Syntax: .dequeue(queueName)
Parameters:
Parameter | Description |
queueName | Optional. String value containing the name of the sequence. The default is fx, the standard effects sequence. |
Description: When .dequeue() is called, the next function is removed from the sequence and then executed. This function in turn triggers (directly or indirectly) a call to .dequeue() so that the sequence can continue.
jquery dequeue() methodexample
<!DOCTYPE html> <html> <head> <style> div { margin:3px; width:50px; position:absolute; height:50px; left:10px; top:30px; background-color:yellow; } div.red { background-color:red; } </style> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <button>开始</button> <div></div> <script> $("button").click(function () { $("div").animate({left:'+=200px'}, 2000); $("div").animate({top:'0px'}, 600); $("div").queue(function () { $(this).toggleClass("red"); $(this).dequeue(); }); $("div").animate({left:'10px', top:'30px'}, 700); }); </script> </body> </html>
Click the "Run instance" button to view the online instance