缓缓滚动到顶部
作者:
Luyc_Han | 来源:发表于
2017-10-25 13:56 被阅读4次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)
}
}
本文标题:缓缓滚动到顶部
本文链接:https://www.haomeiwen.com/subject/xesqpxtx.html
网友评论