.clearQueue() in JQuery


Description: Remove from the queue all items that have not yet been run.

  • version added: 1.4.clearQueue( [ queueName ] )

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

When the .clearQueue() method is called, all functions on the queue that have not been executed are removed from the queue. When used without an argument, .clearQueue() removes the remaining functions from fx, the standard effects queue. In this way it is similar to .stop(true). However, while the .stop() method is meant to be used only with animations, .clearQueue() can also be used to remove any function that has been added to a generic jQuery queue with the .queue() method.


Empty the queue.

<!DOCTYPE html>
div { margin:3px; width:40px; height:40px;
    position:absolute; left:0px; top:30px; 
    background:green; display:none; }
div.newcolor { background:blue; }
  <script src="/scripts/jquery-1.4.js"></script>
	<button id="start">Start</button>
<button id="stop">Stop</button>
<script>$("#start").click(function () {
  $("div").queue(function () {
  $("div").queue(function () {
$("#stop").click(function () {

Leave a Reply

Your email address will not be published. Required fields are marked *