zoukankan      html  css  js  c++  java
  • jquery点击回到顶部

    jquery实现点击回到顶部

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>回到顶部</title>
        <meta name="viewport" content="width=1200, maximum-scale=1.0, user-scalable=1">
        <style>
            .scrollToTop{
                display: block;
                width: 42px;
                height: 42px;
                position: fixed;
                bottom: 5%;
                right: 2%;
                display: none;
                font-size: 40px;
                background: #232323;
                color: #ebebeb;
                border-radius: 3px;
                text-align: center;
                line-height: 38px;
                z-index: 999;
            }
            .scrollToTop i img{margin:9px 0px 0px 2px;}
        </style>
    
    
    </head>
    <body style="height:2000px">
            
    <a href="#" title="sroll" class="scrollToTop"><i><img src="https://www.cnblogs.com/images/cnblogs_com/wrongcode/1426773/o_uptop0.png" alt=""></i></a>
    
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript">
            $(window).scroll(function() {
                if ($(this).scrollTop() > 300) {
                    $('.scrollToTop').fadeIn();
                } else {
                    $('.scrollToTop').fadeOut();
                }
            });
    
            $('.scrollToTop').on("click", function() {
                $('html, body').animate({
                    scrollTop: 0
                }, 800);
                return false;
            });
    </script>
    
    </body>
    </html>
  • 相关阅读:
    linux常用命令使用指南
    小赢理财招聘 测试开发、专项
    小赢理财招聘 测试开发、专项
    【模板】普通平衡树
    about乘法逆元
    luogu P2234 [HNOI2002]营业额统计
    线性筛中求莫比乌斯函数‘
    欧拉函数
    围棋
    丛林中的路
  • 原文地址:https://www.cnblogs.com/wrongcode/p/10584637.html
Copyright © 2011-2022 走看看