web api instance property
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, documentElement.
When in quirks mode, the scrollingElement attribute returns the HTML
body element if it exists and is not potentially scrollable, otherwise it returns null. This may look surprising but is true according to both the specification and browsers.
Value
The Element that scrolls the document, usually the root element (unless not in standard mode).
Examples
const scrollElm = document.scrollingElement;
scrollElm.scrollTop = 0;
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.