jQuery Tutorial

jQuery Stop Animation: stop() Method With Syntax & Example

jQuery stop() function

To stop animations or effects before the end, the jQuery stop() function is used. jQuery stop() method means to halt an animation or effect before it completes.

All jQuery effect functions, including sliding, fading, and custom animations, operate with the stop() method.

Syntax of stop method in jQuery

$(selector).stop(stopAll,goToEnd);

Stopping is a choice. All parameters determine whether or should also be clear of the animation queue. The default value is set to false. It means that only the presently active animation will be paused while all other animations will continue to run.

The goToEnd argument determines whether or not the current animation should be completed immediately. The default value is false.

As a result, the stop() function cancels the current animation on the specified element by default.

The stop() method is demonstrated in the following example, which has no parameters:

Example of jQuery stop animation

$("#stop").click(function(){
  $("#panel").stop();
});
Did you find this article helpful?