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?
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.
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.
The stop() method is an inbuilt method in jQuery which is used to stop the currently running animations for the selected element. Syntax: $(selector).
The stop() method stops the currently running animation for the selected elements.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With