语法
element.scrollTo(x-coord, y-coord) element.scrollTo(options)
参数
例子
element.scrollTo(0, 1000);
使用 options
:
element.scrollTo({
top: 100,
left: 100,
behavior: 'smooth'
});
规范
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) View Module element.scrollTo() |
Working Draft | Initial definition. |
浏览器兼容性
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.