// 页面滚动到顶部 // 方法一 document.body.scrollTop=document.documentElement.scrollTop=0 // 方法二 document.body.scrollIntoView() // scrollIntoView 是元素也有的方法, 可以用在页面元素上,例如 document.getElementById('id').scrollIntoView()
JavaScript滑动页面到顶部的方法。
wanlibingfeng 2019-11-20 17:27 原文
// 页面滚动到顶部 // 方法一 document.body.scrollTop=document.documentElement.scrollTop=0 // 方法二 document.body.scrollIntoView() // scrollIntoView 是元素也有的方法, 可以用在页面元素上,例如 document.getElementById('id').scrollIntoView()
JavaScript滑动页面到顶部的方法。