The dequeue() is an inbuilt method in jQuery which is used to remove the next function from the queue and then it will execute the function. In a queue there will be a several function waiting to run dequeue() used to remove the top function from the queue and execute that function.
Syntax:
$(selector).dequeue(name);
Parameter: It accepts a parameter “name” which specifies the name of the queue.
Return Value : It returns the selected element that perform the given top function.
Code #1:
In the below code, animate method is also used to demonstrate the dequeue method.
<html> <head> <style> div { margin: 15px 0 0 0 ; width: 100px; position: absolute; height: 30px; left: 10px; top: 30px; background-color: lightgreen; text-align: center; padding: 15px; } div.red { background-color: red; } </style> </head> <body> <div>GfG!</div> <!-- click on this button to perform animation --> <button>Click to start !</button> <script> $( "button" ).click(function() { <!--jQuery code to demonstrate animation with the help of dqueue method--> $( "div" ) .animate({ left:"+=500px" }, 1000 ) .animate({ top:"0px" }, 1000 ) .queue(function() { $(this).toggleClass("green").dequeue(); }) .animate({ left:"50px", top:"150px" }, 1000 ); }); </script> </body> </html> |
Output:
Before clicking the “Click to start” button-

After clicking the “Click to start” button-

Recommended Posts:
- p5.js | Dequeue Operation in Queue
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- jQuery | prepend() with Examples
- jQuery | dblclick() with Examples
- jQuery | offset() with Examples
- jQuery | children() with Examples
- jQuery | Hide/Show, Toggle and Fading methods with Examples
- jQuery | focusin() with Examples
- jQuery | Animation, Slide methods with Examples
- jQuery | change() with Examples
- jQuery | filter() with Examples
- jQuery | height() and innerHeight() with Examples
- jQuery | eq() with Examples
- jQuery | empty() with Examples
- jQuery | not() method with Examples
- jQuery | first() with Examples
- jQuery | parent() & parents() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


