1: Define the method.
<script>
// 点击按钮,返回顶部
function toTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>
2: How to use, take button as an example.
<button onclick="toTop()">返回顶部</button>
3: OK.