滚动到页面的指定位置

index.js

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

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

posted on 2021-09-10 09:44  aisowe  阅读(52)  评论(0编辑  收藏  举报

导航