若要使用一般所看到的滑出式選單,只要透過mouseover和mouseleave這兩個event再配合animate就可以完成
例如:
HTML
1 | < div id = "doc" ></ div > |
CSS
1 | #doc { |
2 | width : 200px ; |
3 | height : 50px ; |
4 | background : #999 ; |
5 | position : relative ; |
6 | } |
Javascript
1 | //滑鼠移入 |
2 | $( '#doc' ).mouseover( function () { |
3 | $( this ).stop().animate({left: '50px' },600); |
4 | }); |
5 | //滑鼠移出 |
6 | $( '#doc' ).mouseleave( function () { |
7 | $( this ).stop().animate({left: '0px' },600); |
8 | }); |