Document: scrollingElement property
The scrollingElement read-only property of the
Document interface returns a reference to the Element that
scrolls the document. In standards mode, this is the root element of the
document, document.documentElement.
When in quirks mode, the scrollingElement attribute returns the HTML
body element if it exists and is potentially scrollable, otherwise it returns null.
Value
The Element that scrolls the document, usually the root element (unless not in standard mode).
Examples
js
const scrollElm = document.scrollingElement;
scrollElm.scrollTop = 0;
Specifications
| Specification |
|---|
| CSSOM View Module # dom-document-scrollingelement |
Browser compatibility
BCD tables only load in the browser