返回顶部

 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 <title>无标题文档</title>
 6 </head>
 7 
 8 <body>
 9 <style>
10 #goTopBtn {position: fixed;line-height:36px;width:36px;bottom:35px;height:36px;cursor:pointer;display:none;
11 background:#0000CC;}
12 
13 #goTopBt{height:4000px}
14 </style>
15 <br/>
16 <p style="text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;font-size:24px;font-weight:bold;">***,how are you。
17 <br/>Just do what you want do!!!</p>
18 <div id="goTopBt"></div>
19 <div id="goTopBtn"></div>
20 <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
21 <script type="text/javascript">
22   $(window).scroll(function(){
23      var sc=$(window).scrollTop();
24       if(sc>0){
25     $("#goTopBtn").css("display","block");
26     $("#goTopBtn").css("right","36px")
27     }else{
28    $("#goTopBtn").css("display","none");
29     }
30     })
31      
32    $("#goTopBtn").click(function(){
33    
34    $('body,html').animate({scrollTop:0},500);
35     })  
36    
37 </script>
38 </body>
39 </html>

 

posted @ 2013-08-27 14:37  鲤鱼在睡觉  阅读(173)  评论(0编辑  收藏  举报