window.onload = function () {
let btn = document.getElementById("renturn")
var timer = null
btn.onclick = function () {
timer = setInterval(function () {
let top = document.documentElement.scrollTop || document.body.scrollTop
var ispeed = Math.floor(-top/8)
console.log(top);
if (top == 0) {
console.log('暂停');
clearInterval(timer)
}
document.documentElement.scrollTop = document.body.scrollTop = top + ispeed
},30)
}
}
网友评论