The queue() method is an inbuilt method in jQuery which is used to show the queue of functions to be executed on the selected elements. In a queue one or more function wait for run.
- The queue() method can be used with the dequeue() method.
- An element may have several queues. Generally there is only one default jQuery queue.
Syntax:
$(selector).queue(queue_name)
Parameters: This method accepts single parameter queue_name which is optional. It is used to set the queue name.
Below example illustrates the queue() method in jQuery:
Example:
<!DOCTYPE html> <html> <head> <title>The queue Method</title> <script src= </script> <!-- jQuery code to show the working of this method --> <script> $(document).ready(function() { $("p").click(function() { var div = $("div"); div.animate({ left: "+=200" }, 2000); div.animate({ height: 200 }, "slow"); div.animate({ width: 150 }, "slow"); div.animate({ height: 100 }, "slow"); div.animate({ width: 60 }, "slow"); div.animate({ left: "-=200", top: "+=100" }, 2000); $("span").text(div.queue().length); }); }); </script> <style> div { width: 50px; height: 50px; position: absolute; left: 35px; margin-top: 10px; background-color: green; } body { width: 500px; height: 250px; border: 2px solid green; padding: 20px; } </style> </head> <body> <p>The queue length is: <span></span></p> <!-- click on above paragraph to show the number of times animation method works --> <div></div> </body> </html> |
Output:
Before click on the paragraph element:

After click on the paragraph element:

Recommended Posts:
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- Implementation of Queue in Javascript
- Implementation of Priority Queue in Javascript
- p5.js | Enqueue Operation in Queue
- p5.js | Dequeue Operation in Queue
- How to store JavaScript functions in a queue and execute in that order?
- D3.js queue() Function
- D3.js queue.defer() Function
- D3.js queue.abort() Function
- 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
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.


