function top() { let currentPosition, timer timer = setInterval(function () { currentPosition = document.documentElement.scrollTop || document.body.scrollTop currentPosition -= 10 if (currentPosition > 0) { window.scrollTo(0, currentPosition) } else { window.scrollTo(0, 0) clearInterval(timer) } }, 1) }
top()