File tree Expand file tree Collapse file tree 1 file changed +50
-26
lines changed Expand file tree Collapse file tree 1 file changed +50
-26
lines changed Original file line number Diff line number Diff line change 5
5
< meta http-equiv ="Content-type " content ="text/html; charset=utf-8 " />
6
6
< title > </ title >
7
7
< style >
8
+ p {
9
+ color : red;
10
+ }
11
+
8
12
div {
9
- position : absolute ;
10
- background-color : # abc ;
11
- left : 0 px ;
12
- top : 30 px ;
13
- width : 60 px ;
14
- height : 60 px ;
15
- margin : 5 px ;
13
+ width : 200 px ;
14
+ height : 100 px ;
15
+ background-color : yellow ;
16
+ color : red ;
17
+ }
18
+ a {
19
+ display : block
16
20
}
17
21
</ style >
18
22
< script src ="http://libs.baidu.com/jquery/1.9.1/jquery.js "> </ script >
19
23
</ head >
20
24
21
25
< 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 ="停止动画 ">
26
39
< script type ="text/javascript ">
27
- /* Start animation */
28
- $ ( "#go" ) . click ( function ( ) {
29
- $ ( ".block" ) . animate ( {
30
- left : '+=100px'
31
- } , 2000 ) ;
32
- } ) ;
33
40
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
+ } )
38
53
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
+ }
44
68
} ) ;
45
69
</ script >
46
70
</ body >
You can’t perform that action at this time.
0 commit comments