+
95
-

jquery返回按钮滚定显示并点击返回顶部代码怎么写?

jquery返回按钮滚定显示并点击返回顶部代码怎么写?

网友回复

+
15
-

完整代码如下:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" />
    <title>BFW NEW PAGE</title>
    <script id="bfwone" data="dep=jquery.17&err=0" type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/bfwone.js"></script>
    <script type="text/javascript">
        bready(function() {
           //首先将#back-to-top隐藏
    $("#icon_top").hide();
    //当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失
 
      $(window).scroll(function() {
        if ($(window).scrollTop() > 100) {
          $("#icon_top").fadeIn(1500);
        } else {
          $("#icon_top").fadeOut(1500);
        }
      });
      //当点击跳转链接后,回到页面顶部位置
      $("#icon_top").click(function() {
        $('body,html').animate({
          scrollTop: 0
        },
        1000);
        return false;
   
    });
        });
    </script>

    <style type="text/css">
        /* fixed */
        .fixed {
            position: fixed;
           
            height: auto;
            right: 15px;
            top: 250px;
            z-index: 800;
        }
    
        .fixed li {
            list-style: none;
            width: 115px;
            height: auto;
            max-height: 234px;
        }
    
        .fixed li img {
            width: 100%;
        }
    
      
        #icon_top {
            display: none;
        }
    </style>

</head>

<body>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>
    <p>内容</p>...

点击查看剩余70%

我知道答案,我要回答