返回顶部的js

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 2     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 3 <html>
 4 <head>
 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 6 <title>dom</title>
 7 <style>
 8 * {
 9     margin:0;
10     padding:0;
11 }
12 .toTop {
13     display:inline-block;
14     width:30px;
15     height:30px;
16     background-color:#969;
17     fond-size:22px;
18     line-height:30px;
19     text-align:center;
20     position:fixed;
21     bottom:50px;
22     right:20px;
23     color:#fff;
24     cursor:pointer;
25 }
26 </style>
27 </head>
28 <body>
29     <p>2</p><p>121</p><p>121</p><p>121</p><p>0</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>7</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121121121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>5</p><p>121</p><p>121121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>9</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121121121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p><p>121</p>
30     <a class="toTop"></a>
31 <script src="../../../../js/jquery.min.js"></script>
32 <script>
33     $('.toTop').click(function(){
34         $('body').stop().animate({scrollTop:$('body').offset().top},500);  //{scrollTop:0}
35         return false;    
36     });
37 
38     /*jQuery.fn.scrollTo = function(speed){
39         var $target = $(this).offset().top;
40         $('html,body').stop().animate({scrollTop:$target},speed)    
41     };
42     $(function(){
43         $('.toTop').click(function(){
44             $('body').scrollTo(500);
45             return false;    
46         });
47     });*/
48 </script>
49 </body>
50 </html>

 

posted on 2016-05-29 00:54  jasonduanmu  阅读(119)  评论(0编辑  收藏  举报

导航