码迷,mamicode.com
首页 > 其他好文 > 详细

回到顶部 插件

时间:2015-06-26 16:13:11      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <title>回到顶部</title>
  <script type="text/javascript" src="js/jquery.js"></script>
  <script type="text/javascript" src="js/popwin.js"></script>
  <style>
    html,body {height:3200px}
    html,body,form,input,span,p,img,ul,ol,li,dl,dt,dd {margin:0; padding:0;border:0}
    a { text-decoration:none}
       a:hover {text-decoration:underline}
      #moquu_top{ z-index:2;width:50px;height:50px;right:30px; position:fixed;cursor:pointer;bottom:60px;background:#f00 url(../images/sbtn.png) 0 -101px;}
      #moquu_top:hover {background:#ff0 url(../images/sbtn.png) -50px -101px}
</style> </head> <body> <a id="moquu_top" href="javascript:"></a> </body> </html>
//返回顶部
function b() {
    h = $(window).height(),
    t = $(document).scrollTop()+h,
    t > h ? $("#moquu_top").show() : $("#moquu_top").hide()
}
$(document).ready(function() {
    b(),
    $("#moquu_top").click(function() {
        $(document).scrollTop(0)
    })
}),
$(window).scroll(function() {
    b()
});

 

 

回到顶部 插件

标签:

原文地址:http://www.cnblogs.com/qianrong/p/4602485.html

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