Clearing the queue

As well as viewing the queue and manipulating its contents, we can also remove all of the functions from it entirely. jQuery provides the clearQueue() method allowing us to easily clear all functions in the specified element's queue.

Like dequeue(), this is a simple method that takes just a single optional argument:

jQuery(elements).clearQueue([queue name]);

This method is generally used with non-animation-based queues, when using the stop() method is not possible, and so will not be discussed further.

Note

Passing an empty array to the queue() method will also clear the queue.

Get jQuery 1.4 Animation Techniques Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.