对于stop()函数,有说的价值的的其括号里能够填的两个参数。
stop()函数的原型是这样的:stop(stopall,finish);stopall和finish是其两个参数,取值为true或false。
stopall取值为true会使动画队列中所有动作停止,否则只停止当前动作,紧接着进行动画队列中的下一动作。
finish取值为true会使当前动作立刻跳到结尾然后停止(不管当前动作进行至什么进度)(这里单独研究finish,不涉及stopall,所以只谈当前动作,而不涉及动画队列中的下一动作),否则会使当前动作在进行的进度处停止,不会跳到结尾。
stopall和finish默认值都是false,并且stop(true)等价于stop(true,false)
最后提供代码供调试
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style>
p
{
height:200px;
width:200px;
background-color:#99ff99;
position:relative;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#start").click(function(){
$("#a1").animate({left:"400px"},5000);
$("#a1").animate({top:'400px'},5000);
$("#a1").animate({left:"0px"},5000);
$("#a1").animate({top:"0px"},5000);
});
$("#end").click(function(){
$("#a1").stop(false,true);
});
});
</script>
</head>
<body>
<button id="start">开始动画</button>
<button id="end">停止</button>
<p id="a1"></p>
</body>
</html>
以上就是jQuery stop()函数详解的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号