欢迎访问 如意编程网!

如意编程网

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

[html] 回到页首

发布时间:2022/11/16 HTML 31 老码农
如意编程网 收集整理的这篇文章主要介绍了 [html] 回到页首 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
[转]本文来自:最简单最强大的插件框架(Net 2.0+) http://www.cnblogs.com/baihmpgy/p/3305215.html
<!doctype html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style type="text/css">
    #toTop{
        width:100px;
        border:1px solid #ccc;
        background:#f7f7f7;
        text-align:center;
        padding:5px;
        position:fixed;
        bottom:10px;
        right:10px;
        cursor:pointer;
        display:none;
        color:#333;
        font-size:11px;
    }
  </style>
 </head>
 <body>
  <div style="height:2000px;">http://www.iopenworks.com/Documents/DocumentsList</div>
  <script src="js/jquery.min.js" type="text/javascript"></script>
  <script type="text/javascript">
        $(document).ready(function () {
            $('#Documents').addClass("currentPage");
            $(window).scroll(function () {
                if ($(this).scrollTop() > 200) {
                    $('#toTop').fadeIn();
                } else {
                    $('#toTop').fadeOut();
                }
            });

            $('#toTop').click(function () {
                $('body,html').animate({ scrollTop: 0 }, 800);
            });
        });    
  </script>

  <div id="toTop">^ Top</div>
 </body>
</html>

 

总结

以上是如意编程网为你收集整理的[html] 回到页首的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得如意编程网网站内容还不错,欢迎将如意编程网推荐给好友。