jquery运动

animate()宽高不能设添 px  stop() finish()

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
	.div1{
		background: red;
		width: 100px;
		height: 100px;
	}
	.div2{
		background: yellow;
		width: 50px;
		height: 50px;
	}
	.div3{
		background: blue;
		width: 50px;
		height: 50px;
	}
	.div4{
		background: #ccc;
		width: 50px;
		height: 50px;
	}
	</style>
	<script src="jquery-2.1.4.js"></script>
	<script>
	$(function(){
		/*第一个参数:{}运动的属性和值
		  第二个参数:时间 默认400毫秒
		  第三个参数:运动形式 默认swing(慢快慢),linear(匀速)
		  第四个参数:callback回调函数
		*/
		$('.div1').click(function(){
			$(this).animate({width: 400},4000).animate({height: 500},4000);
		});
		$('.div2').click(function(){
			$('.div1').stop();//只能阻止当前运动,即animate({width: 400},4000)无效,animate({height: 500},4000)有效
		});
		$('.div3').click(function(){
			$('.div1').stop(true);//阻止所有运动,animate({width: 400},4000).animate({height: 500},4000)都无效
	    });
	    $('.div4').click(function(){
			$('.div1').finish();//快速停止到指定目标点
		});
	});
	</script>
</head>
<body>
	<div class="div1"></div>
	<br/>
	<div class="div2"></div>
	<br/>
	<div class="div3"></div>
	<br/>
	<div class="div4"></div>
</body>
</html>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值