jQuery | Stop Animations
The jQuery stop() method in jQuery is used to stop animations or effects before it is finished.
This method works on all type of animation like sliding, fading, and custom animations.
Syntax:
$(selector).stop(stopAll, goToEnd);
Example-1: Stop sliding animation.
<!DOCTYPE html> <html> <head> <title>jQuery stop() Method </title> <script src= </script> <style> #panel, #flip { padding: 5px; font-size: 18px; text-align: center; background-color: green; color: white; border: solid 1px #666; border-radius: 3px; } #panel { padding: 50px; display: none; } </style> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks</h1> <h2 id="GFG"> jQuery stop() Method</h2> <br> <button id="stop">Click </button> <br> <br> <div id="flip"> <h2>GeeksForGeeks</h2></div> <div id="panel"> A computer science portal for geeks </div> <script> $(document).ready(function() { $("#flip").click(function() { $("#panel").slideDown(5000); }); $("#stop").click(function() { $("#panel").stop(); }); }); </script> </center> </body> </html> |
Output:
Before clicking on the GeeksForGeeks:

After clicking on the GeeksForGeeks and not clicking on Button:

After clicking on the GeeksForGeeks and click on Button:

Example-2: Stop sliding from left to right.
<!DOCTYPE html> <html> <head> <title>jQuery stop() Method</title> <script src= </script> <style> #panel, #flip { padding: 5px; font-size: 18px; text-align: center; background-color: green; color: white; border: solid 1px #666; border-radius: 3px; } #panel { padding: 50px; display: none; } </style> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks</h1> <h2 id="GFG"> jQuery stop() Method</h2> <br> <button id="start">Start</button> <button id="stop">Stop</button> <br> <br> <div style="background:green; height:100px; width:400px; position:absolute;"> GeeksForGeeks </div> <script> $(document).ready(function() { $("#start").click(function() { $("div").animate({ left: '80px' }, 5000); $("div").animate({ fontSize: '3em' }, 5000); }); $("#stop").click(function() { $("div").stop(); }); }); </script> </center> </body> </html> |
Output:
Before clicking on the Start:

After clicking on the Start and not clicking on Stop:

After clicking on the Start and clicking on Stop:

Recommended Posts:
- jQuery | stop() with Examples
- CSS | Animations
- AngularJS | Animations
- CSS | Scroll Snap stop
- HTML | DOM Window stop() Method
- HTML | Marquee stop Method
- How to stop browser back button using JavaScript ?
- How to stop event propagation with inline onclick attribute in JavaScript ?
- jQuery | jQuery.support Property
- jQuery | jQuery.fx.interval Property with example
- jQuery | jquery Property
- jQuery | jQuery.fx.off Property
- jQuery | :first Selector
- jQuery UI | beforeShowDay
- jQuery | :even Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



