jQuery dequeue()

Introduction

dequeue() remove the next function from the queue, and then execute the function.

The queue() method creates a queue of functions to be executed on selected elements.

The dequeue() method executes them in order.

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>/*from   w  ww  .  ja  v  a  2 s  .  c  o m*/
<script>
$(document).ready(function(){
  $("#start").click(function(){
    var div = $("div");
    div.animate({height: 300}, "slow");
    div.animate({width: 300}, "slow");
    div.queue(function(){
      div.css("background-color", "red");
      div.dequeue();
    });
    div.animate({height: 100}, "slow");
    div.animate({width: 100}, "slow");
  });
});
</script>
</head>
<body>


<p><button id="start">Start Animation</button></p>

<div style="background:blue;height:100px;width:100px;">

</div>

</body>
</html>

The dequeue() method removes the next function from the queue, and then executes the function.

An element can have several queues.

$(selector).dequeue(queueName)
Parameter
Optional
Description
queueName

Optional.

name of the queue
Default is "fx", the standard effects queue



PreviousNext

Related