JQ中stop传参理解

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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值