var getTop = document.getElementById("get-top");
var head = document.getElementById("head");
getTop.onclick = function () {
    var time = setInterval(function () {
        document.body.scrollTop = document.body.scrollTop - 50;
        if (document.body.scrollTop === 0) {
            clearInterval(time);
        }
    }, 1);

};

链接:https://segmentfault.com/q/1010000003855799

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-12-03
  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
  • 2021-05-23
  • 2021-12-15
  • 2021-10-20
  • 2022-12-23
相关资源
相似解决方案