jQuery API

.dequeue()

.dequeue( [queueName] ) Returns: jQuery

Description: Execute the next function on the queue for the matched elements.

  • version added: 1.2.dequeue( [queueName] )

    queueNameA string containing the name of the queue. Defaults to fx, the standard effects queue.

When .dequeue() is called, the next function on the queue is removed from the queue, and then executed. This function should in turn (directly or indirectly) cause .dequeue() to be called, so that the sequence can continue.

Example:

Use dequeue to end a custom queue function which allows the queue to keep going.

<!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 src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <button>Start</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>

Demo:

Support and Contributions

Need help with .dequeue() or have a question about it? Visit the jQuery Forum or the #jquery channel on irc.freenode.net.

Think you've discovered a jQuery bug related to .dequeue()? Report it to the jQuery core team.

Found a problem with this documentation? Report it on the GitHub issue tracker

  • Alman66

    The description of the dequeue() function is too blurry. It's missing a basic introduction to the queque principle, how queued animation functions work etc. Just two or three short paragraphs.

    • Thamus

      I agree with Alman66. The information to be gained by reading this vague piece of documentation confines itself to the mere fact that there is a method called .dequeue(), which can be used to alter the effect chaining behavour.
      I had to take a look at the jQuery source to understand what it is actually good for.

  • Thamus

    I agree with Alman66. The information to be gained by reading this vague piece of documentation confines itself to the mere fact that there is a method called .dequeue(), which can be used to alter the effect chaining behavour.
    I had to take a look at the jQuery source to understand what it is actually good for.