JQuery stop()
The stop()
method in jQuery is used to stop the execution of an animation or effect that is currently running.
Syntax
The syntax for the stop()
method is as follows:
$(selector).stop(stopAll,goToEnd);
- The
selector
parameter specifies the element(s) to stop the animation on. - The
stopAll
parameter is optional and specifies whether to stop the animation for all elements in the selector or just the first one. It can have a boolean value oftrue
orfalse
. The default value isfalse
. - The
goToEnd
parameter is optional and specifies whether to immediately complete the animation and jump to the end state. It can have a boolean value oftrue
orfalse
. The default value isfalse
.
Use
The stop()
method is commonly used when you need to interrupt and stop an animation or effect, either because the user interacts with the page or because some other event occurs that requires the animation to be stopped.
Example
Here is an example of how to use the stop()
method to interrupt and stop a simple animation: