Net-informations.com
SiteMap  | About    

jQuery stop() Vs. finish()



jQuery stop()

When .stop() is called on an element, the currently-running animation (if any) is immediately stopped. The stop() method works for all jQuery effect functions , including sliding, fading and custom animations.

If more than one animation method is called on the same element, the later animations are placed in the effects queue for the element. These animations will not begin until the first one completes. When .stop() is called, the next animation in the queue begins immediately. The .stop() without parameters simply stops the animation, still leaving it in queue. In this case you want .stop(true) to clear the animation queue as well.

example

The following example will show three button (start, stop and stop(true). When you press start button then the animation will start. When you press stop button, you can see the current animation will stop and it jumped to the next animation , , still leaving it in queue. When you press Stop(true) button to clear the animation queue as well.

run this source code Try it Yourself
jQuery dequeue()

Full Source

jQuery finish()

jQuery finish() method stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements. when you call $.finish() , jQuery applies the same CSS to the given set of elements that would have been applied if all of the animations had been allowed to finish naturally.

Syntax

If the first argument is provided, only the animations in the queue represented by that string will be stopped.

run this source code Try it Yourself
jQuery finish()

example

jQuery Stop() Vs finish()

jQuery stop() and finish() methods are used to end of all of the queued animations. jQuery finish() method was added in jQuery 1.9 and works similarly to the old $.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.









net-informations.com (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.