jQuery stop animation
jQuery stop animation
Example
jQuery stop() sliding
Demo jQuery stop() method.
jQuery stop() animation (with parameters)
Demo jQuery stop() method
jQuery stop() method
jQuery stop() method is used to stop animations or effects before they are completed.
The stop() method works with all jQuery effect functions, including slides, fades, and custom animations.
Syntax:
The optional stopAll parameter specifies whether the animation queue should be cleared. The default is false, which only stops active animations, allowing any queued animations to execute backwards.
The optional goToEnd parameter specifies whether to complete the current animation immediately. The default is false.
So, by default, stop() will clear the current animation specified on the selected element.
The following example demonstrates the stop() method without parameters:
Example
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#flip").click(function(){ $("#panel").slideDown(5000); }); $("#stop").click(function(){ $("#panel").stop(); }); }); </script> <style type="text/css"> #panel,#flip { padding:5px; text-align:center; background-color:#e5eecc; border:solid 1px #c3c3c3; } #panel { padding:50px; display:none; } </style> </head> <body> <button id="stop">停止滑动</button> <div id="flip">点我向下滑动面板</div> <div id="panel">Hello world!</div> </body> </html>
Running Example»
Click the "Run Instance" button to view the online instance