滚动到页面的指定位置

index.js

window.scrollTo(x, y); // 绝对值滚动
window.scrollBy(x, y); // 相对值滚动

注意:如果不是要滚动整个文档,而是要滚动某个元素,可以使用:Element.scrollTop()、Element.scrollLeft()、Element.scrollIntoView()。

原文地址:https://www.cnblogs.com/aisowe/p/15250050.html