stop([clearQueue],[jumpToEnd])
概述
停止所有在指定元素上正在运行的动画。
如果队列中有等待执行的动画(并且clearQueue没有设为true),他们将被马上执行
参数
[clearQueue],[gotoEnd]Boolean,BooleanV1.2
clearQueue:如果设置成true,则清空队列。可以立即结束动画。
gotoEnd:让当前正在执行的动画立即完成,并且重设show和hide的原始样式,调用回调函数等。
[queue],[clearQueue],[jumpToEnd]BooleanV1.7
queue:用来停止动画的队列名称
clearQueue:如果设置成true,则清空队列。可以立即结束动画。
jumpToEnd:如果设置成true,则完成队列。可以立即完成动画。
通过以下运行一下代码即可理解
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style type="text/css">
div{
position: absolute;
width: 80px;
height: 80px;
background-color: orange;
left: 100px;
top: 100px;
}
</style>
</head>
<body>
<input type="button" value="开始动画"/>
<input type="button" value="不清空队列向上移动"/>
<input type="button" value="清空队列向上移动"/>
<input type="button" value="清空队列并完成当前动画向上移动"/>
<input type="button" value="不清空队列并完成当前动画向上移动"/>
<div></div>
<hr style="width:100%;height:2px;top:600px;position:absolute;"/>
<label style="top:600px;position:absolute;" > 下滑动画的终点</label>
<script src="https://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script >
<script type="text/javascript">
$("input:eq(0)").click(function(){
$("div").css({top:100,left:100})
$("div").stop(true).animate({top:600},3000).animate({left:900},3000);
});
$("input:eq(1)").click(function(){
$("div").stop(false).animate({top:0},1000);
});
$("input:eq(2)").click(function(){
$("div").stop(true).animate({top:0},1000);
});
$("input:eq(3)").click(function(){
$("div").stop(true,true).animate({top:0},1000);
});
$("input:eq(4)").click(function(){
$("div").stop(false,true).animate({top:0},1000);
});
</script>
</body>
</html>