jquery---stop()

1.测试代码

<!doctype html>
<html>
	<head lang='en'>
		<meta charset='utf-8'></meta>
		<style>
		#animater{
		                width: 150px;
		                background:;
		                border: 1px solid black;
		                /*为了移动,需设置此属性*/
		                position: relative;
		            }
		</style>		
	</head>
	<body>
		<div id="animater">
		            stop()方法测试
		        </div>

		        <div id="button">
		            <input type="button" id="button1" value="stop()"/>
		            <input type="button" id="button2" value="stop(true)"/>
		            <input type="button" id="button3" value="stop(false,true)"/>
		            <input type="button" id="button4" value="stop(true,true)"/>
		            
		</div>		
		<script type="text/javascript" src="jquery-2.1.1.min.js"></script>
		<script>
			//            为了看效果,随意写的动画
		                $('#animater').animate({
		                    'right':-800
		                }, 3000).animate({'font-size':'16px'},'normal').animate({'font-size':'26px'},'normal').animate({'font-size':'36px'},'normal').animate({'font-size':'46px'},'normal').animate({'font-size':'56px'},'normal').animate({'opacity':0},'normal').animate({'opacity':1},'normal').animate({'left':200,'font-size':'16px'},'normal');



		        
		                //           点击不同的button执行不同的操作
		        
		                $('#button1').click(function(){
		                    //默认参数是false,不管写一个false还是两个false还是没写false效果一样
		                    $('#animater').stop();
		                });
		                $('#button2').click(function(){
		                    //第二个参数默认false
		                    $('#animater').stop(true);
		                });
		                $('#button3').click(function(){
		                    $('#animater').stop(false,true);
		                });
		                $('#button4').click(function(){
		                    $('#animater').stop(true,true);
		                });
		</script>
	</body>
</html>

2.截图:试点击这四个按钮测试,stop()在不同参数下的性能:

  

 

3.结果:

stop():的默认值是stop(false,false),第一个animate停止,接下来的其他animate都依次执行;

stop(true):第一个animate停止,接下来的其他animate都停止;

stop(false,true):第一个animate跳到最终结果,接下来的animate继续依次执行,最后停止在第一个animate起跳之前的状态;

stop(true,true):第一个animate跳到最终结果,接下来的其他animate都停止;

转载于:https://www.cnblogs.com/IanI/p/4019527.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值