jQuery clearQueue() with Examples

The clearQueue() method in jQuery is used to remove all items from the queue.


The syntax is as follows −


Above, the queue is the name of the queue.


Let us now see an example to implement the jQuery clearQueue() method 

 Live Demo

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
         var div = $("div");
         div.animate({height: 250}, "slow");
         div.animate({left: "+=200",top: "+=100" }, "slow");
div {
<button class="button1">Start</button>
<button class="button2">End</button>
<p>Length = <span></span></p>


This will produce the following output −

Above, click “Start” to begin the animation −

Now, you can also press “Stop” to stop the animation anywhere in between −