码迷,mamicode.com
首页 > Web开发 > 详细

返回顶部的js

时间:2016-05-29 06:15:40      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

 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>

 

返回顶部的js

标签:

原文地址:http://www.cnblogs.com/vscss/p/5538775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!