JavaScript滑动页面到顶部

// 页面滚动到顶部
// 方法一
document.body.scrollTop=document.documentElement.scrollTop=0
// 方法二
document.body.scrollIntoView()

// scrollIntoView 是元素也有的方法, 可以用在页面元素上,例如
document.getElementById('id').scrollIntoView()

posted @ 2020-07-20 15:09  番茄匠Amy  阅读(919)  评论(0编辑  收藏  举报