Skip to content

Commit 7072763

Browse files
committed
stop
1 parent 48c92b4 commit 7072763

File tree

1 file changed

+50
-26
lines changed
  • 慕课网教程案例/jQuery入门教程/自定义动画

1 file changed

+50
-26
lines changed

慕课网教程案例/jQuery入门教程/自定义动画/stop.html

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,66 @@
55
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
66
<title></title>
77
<style>
8+
p {
9+
color: red;
10+
}
11+
812
div {
9-
position: absolute;
10-
background-color: #abc;
11-
left: 0px;
12-
top: 30px;
13-
width: 60px;
14-
height: 60px;
15-
margin: 5px;
13+
width: 200px;
14+
height: 100px;
15+
background-color: yellow;
16+
color: red;
17+
}
18+
a{
19+
display: block
1620
}
1721
</style>
1822
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
1923
</head>
2024

2125
<body>
22-
<button id="go">Go</button>
23-
<button id="stop">STOP!</button>
24-
<button id="back">Back</button>
25-
<div class="block"></div>
26+
<h2>stop</h2>
27+
<p>慕课网,专注分享</p>
28+
<div id="aaron">内部动画</div>
29+
<input id="exec" type="button" value="执行动画"><br /><br />
30+
31+
点击观察动画效果:
32+
<select id="animation">
33+
<option value="1">stop()</option>
34+
<option value="2">stop(true)</option>
35+
<option value="3">stop(true,true)</option>
36+
</select>
37+
<a></a>
38+
<input id="stop" type="button" value="停止动画">
2639
<script type="text/javascript">
27-
/* Start animation */
28-
$("#go").click(function() {
29-
$(".block").animate({
30-
left: '+=100px'
31-
}, 2000);
32-
});
3340

34-
/* Stop animation when button is clicked */
35-
$("#stop").click(function() {
36-
$(".block").stop();
37-
});
41+
//点击执行动画
42+
$("#exec").click(function(){
43+
$("#aaron").animate({
44+
height: 300
45+
}, 5000)
46+
$("#aaron").animate({
47+
width: 300
48+
}, 5000)
49+
$("#aaron").animate({
50+
opacity: 0.6
51+
}, 2000)
52+
})
3853

39-
/* Start animation in the opposite direction */
40-
$("#back").click(function() {
41-
$(".block").animate({
42-
left: '-=100px'
43-
}, 2000);
54+
55+
$("#stop").click(function() {
56+
var v = $("#animation").val();
57+
var $aaron = $("#aaron");
58+
if (v == "1") {
59+
//当前当前动画
60+
$aaron.stop()
61+
} else if (v == "2") {
62+
//停止所以队列
63+
$aaron.stop(true)
64+
} else if (v == "3") {
65+
//停止动画,直接跳到当前动画的结束
66+
$aaron.stop(true,true)
67+
}
4468
});
4569
</script>
4670
</body>

0 commit comments

Comments
 (0)