Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery: What is the difference between stop(true) and clearQueue()

Tags:

jquery

What is the difference between using a stop() with the clearQueue parameter set to true and just using the clearqueue(), and if there is no difference why both?

like image 624
Mr. Smee Avatar asked Mar 29 '11 00:03

Mr. Smee


People also ask

What is clearQueue in jQuery?

jQuery clearQueue() Method The clearQueue() method removes all items from the queue that have not yet been run. Note that when a function has started to run, it runs until it is completed. Related methods: queue() - Shows the queued functions.

What is the difference between calling stop true true and finish method?

jQuery Stop() Vs finish() stop() method with one very important difference: jQuery stop() method stops the currently running animation on the matched elements but jQuery finish() stops the currently running animation, removes all the queued animations and complete all the animations for the matched elements.

What is stop () method?

The stop() method is an inbuilt method in jQuery which is used to stop the currently running animations for the selected element. Syntax: $(selector).

How do you stop a function from execution in jQuery?

The stop() method stops the currently running animation for the selected elements.


1 Answers

From the api docs, .stop() is meant only for animation, however .clearqueue() will remove any function attached to a standard jquery queue.

From the docs:

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.

like image 82
Mark Coleman Avatar answered Nov 15 '22 04:11

Mark Coleman