$(function() {

            $(window).scroll(function() {
                if ($(window).scrollTop() > 200) {
                    $('#gotop').fadeIn(500);
                } else {
                    $("#gotop").fadeOut(500);
                }
            });
            $("#gotop").click(function() {
                $('body,html').animate({
                    scrollTop: '0'
                }, 300);
                return false; //防止默认事件行为
            })

        })
<div class="public-gotop" id="gotop">回到顶部</div>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
猜你喜欢
  • 2022-12-23
  • 2021-06-24
  • 2021-11-01
  • 2021-04-03
相关资源
相似解决方案