JavaScript滑動頁面到頂部


// 頁面滾動到頂部
// 方法一
document.body.scrollTop=document.documentElement.scrollTop=0
// 方法二
document.body.scrollIntoView()

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM