首页 > 前端
返回顶部代码
来源:TP课堂 时间:2022-12-19 点击:394

html:

<div class="goup"><i class="iconfanhuidingbu iconfont"></i></div>


css:

.goup{

    position: fixed;

    right: 15px;

    bottom: 50px;

    cursor: pointer;

}


js:

$(function() { 

        $(window).scroll(function() { 

            if ($(window).scrollTop() > 700) $('div.goup').show(); 

            else

            $('div.goup').hide();

        }); 

            $('div.goup').click(function() { $('html, body').animate({scrollTop: 0}, 1000);

        });

  });