???????????СС??????jQuery????????????animate()??????????????.
????????????·??????????????
???????????
????1 $(function(){
????2     $("#toTop").click(function(){
????3         $("html").animate({"scrollTop": "0px"}??100); //IE??FF
????4         $("body").animate({"scrollTop": "0px"}??100); //Webkit
????5         });
????6     })
????????????
????function toTop(){
????window.scroll(0??0);
????}
????????????
????<a href="#">Back to top</a>
???????????£?
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <!-- ?? Bootstrap ???? CSS ??? -->
6 <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap.min.css">
7
8 <!-- ?????Bootstrap?????????????????? -->
9 <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
10
11 <!-- jQuery??????????bootstrap.min.js ?????? -->
12 <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
13
14 <!-- ?μ? Bootstrap ???? JavaScript ??? -->
15 <script src="http://cdn.bootcss.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
16
17 <!--???????????-->
18 <script type="text/javascript">
19 //?????
20 $(function(){
21     //$("#toTop").click(function(){
22 //        $("html").animate({"scrollTop": "0px"}??100); //IE??FF
23 //        $("body").animate({"scrollTop": "0px"}??100); //Webkit
24 //        });
25     })
26 //??????
27     function toTop(){
28         window.scroll(0??0);
29         }
30 </script>
31 <title>????????</title>
32 </head>
33
34 <body>
35 <div style="margin:0 auto; width:1000px;">
36 <button class="btn" value="First">Bootstrap Button</button> <input type="text" value="????????‘???????’???" class="text-center" style="color:#F00; width:200px;" />
37 <p>???????????嶯????????????????????????????????????????????????????????????????????animate???????????????????????????????1?</p>
38 <p>?????:jQueryanimate(params?? [duration]?? [easing]?? [callback])
39 ????
40 ???????????嶯?????????
41 ???????????????????????????????????????????????????????????????????仯????????????“height”??“top”??“opacity”????????????????????????????????????????marginLeft????margin-left.
42 ????????????????????????????????????????????????????????????????????????????????????????“hide”??“show”??“toggle”???????????????????????????????????????
43 ?? jQuery 1.2 ?У????????? em ?? % ??λ???????? jQuery 1.2 ?У?????????????????????? "+=" ?? "-=" ?????????????????
44 jQuery 1.3?У????duration???0?????????????????????汾????????????????
45 ????
46 paramsOptions????????????????????????????????????????
47 duration (???)String??Number???????????????????("slow"?? "normal"?? or "fast")???????????????????(?磺1000)
48 easing (???)String????????Ч????????(?????????).???jQuery??"linear" ?? "swing".
49 callback (???)Function???????????е????
50 ???
51 ????:
52 ????????div?????????????????仯
53 HTML ????: </p>
54 <p>?????:jQueryanimate(params?? [duration]?? [easing]?? [callback])
55 ????
56 ???????????嶯?????????
57 ???????????????????????????????????????????????????????????????????仯????????????“height”??“top”??“opacity”????????????????????????????????????????marginLeft????margin-left.
58 ????????????????????????????????????????????????????????????????????????????????????????“hide”??“show”??“toggle”???????????????????????????????????????
59 ?? jQuery 1.2 ?У????????? em ?? % ??λ???????? jQuery 1.2 ?У?????????????????????? "+=" ?? "-=" ?????????????????
60 jQuery 1.3?У????duration???0?????????????????????汾????????????????
61 ????
62 paramsOptions????????????????????????????????????????
63 duration (???)String??Number???????????????????("slow"?? "normal"?? or "fast")???????????????????(?磺1000)
64 easing (???)String????????Ч????????(?????????).???jQuery??"linear" ?? "swing".
65 callback (???)Function???????????е????
66 ???
67 ????:
68 ????????div?????????????????仯
69 HTML ????: </p>
70 <p>?????:jQueryanimate(params?? [duration]?? [easing]?? [callback])
71 ????
72 ???????????嶯?????????
73 ???????????????????????????????????????????????????????????????????仯????????????“height”??“top”??“opacity”????????????????????????????????????????marginLeft????margin-left.
74 ????????????????????????????????????????????????????????????????????????????????????????“hide”??“show”??“toggle”???????????????????????????????????????
75 ?? jQuery 1.2 ?У????????? em ?? % ??λ???????? jQuery 1.2 ?У?????????????????????? "+=" ?? "-=" ?????????????????
76 jQuery 1.3?У????duration???0?????????????????????汾????????????????
77 ????
78 paramsOptions????????????????????????????????????????
79 duration (???)String??Number???????????????????("slow"?? "normal"?? or "fast")???????????????????(?磺1000)
80 easing (???)String????????Ч????????(?????????).???jQuery??"linear" ?? "swing".
81 callback (???)Function???????????е????
82 ???
83 ????:
84 ????????div?????????????????仯
85 HTML ????: </p>
86 <p>?????:jQueryanimate(params?? [duration]?? [easing]?? [callback])
87 ????
88 ???????????嶯?????????
89 ???????????????????????????????????????????????????????????????????仯????????????“height”??“top”??“opacity”????????????????????????????????????????marginLeft????margin-left.
90 ????????????????????????????????????????????????????????????????????????????????????????“hide”??“show”??“toggle”???????????????????????????????????????
91 ?? jQuery 1.2 ?У????????? em ?? % ??λ???????? jQuery 1.2 ?У?????????????????????? "+=" ?? "-=" ?????????????????
92 jQuery 1.3?У????duration???0?????????????????????汾????????????????
93 ????
94 paramsOptions????????????????????????????????????????
95 duration (???)String??Number???????????????????("slow"?? "normal"?? or "fast")???????????????????(?磺1000)
96 easing (???)String????????Ч????????(?????????).???jQuery??"linear" ?? "swing".
97 callback (???)Function???????????е????