<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery.min.js"></script>
</head>
<body>
<button id="go">Go</button> <button id="stop2">STOP!</button><button id="stop">STOP!</button>
<div style="border: 1px solid red;" class="block"></div>
</body>
<script>
// 开始动画
$("#go").click(function(){
$(".block").animate({height:210}, 5000);
});
// 当点击按钮后停止动画
$("#stop2").click(function(){
$(".block").stop();
});
// 当点击按钮后停止动画,并复原
$("#stop").click(function(){
$(".block").stop().animate({ height: "0" },0);
});
</script>
</html>
转载于:https://my.oschina.net/u/2351011/blog/1827971