这篇文章主要介绍了jquery动画animate的stop方法使用,需要的朋友可以参考下
animate语法:
代码如下:
$(selector).animate(styles,speed,easing,callback)
代码如下:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>Testing</title> <link rel="stylesheet" href="css/reset.css"> <script src="js/jquery.js"></script> <style> .wrap { position : relative; height : 300px; width: 300px; border:5px solid #FCF; } .wrap p { position: absolute; left: 0;top: 0; height: 50px; width: 50px; background : #FA0; } </style> </head> <body> <input type="button" id="btn1" value="停止当前动画"> <input type="button" id="btn2" value="停止所有动画"> <input type="button" id="btn3" value="停止所有动画,到达终点"> <p class="wrap"> <p></p> </p> <script> function moveX(){ $('.wrap p').animate({'left':'250px'},1000).animate({'left':'0px'},1000); } moveX(); $('#btn1').click(function(){ $('.wrap p').stop(); // 停止当前动画,沿路返回起点,若是返回过程中再点击,会暂停在路中 clearInterval(); }) $('#btn2').click(function(){ $('.wrap p').stop(true); // 停止所有动画 去的路程中点击停止会直接到达终点,若是返回过程中再点击,会暂停在路中 }) $('#btn3').click(function(){ $('.wrap p').stop(true,true); // 停止所有动画 ,去的路程中点击停止会直接到达终点,若是返回过程中再点击,会停止到在起点 }) // .stop() // 停止当前动画 // .stop(true) // 停止所有动画 // .stop(true,true) // 停止所有动画,到达动画终点 </script> </body> </html>
.stop(); // 停止当前动画,沿路返回起点,若是返回过程中再点击,会暂停在路中
.stop(true); // 停止所有动画 去的路程中点击停止会直接到达终点,若是返回过程中再点击,会暂停在路中
.stop(true,true); // 停止所有动画 ,去的路程中点击停止会直接到达终点,若是返回过程中再点击,会停止到在起点
以上就是JQuery动画animate的stop方法使用详解的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号