getScrollParent
Commons
stable
Walks the DOM ancestor chain of an element and returns the first parent that has a visible scrollbar (or any potential scroll container when includeHidden is true).
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- elHTMLElement
- The element to start from. When omitted, returns document.scrollingElement.
- includeHiddenbooleanfalse
- When true, elements with overflow: scroll or overflow: auto (even without visible scrollbar) are included. Defaults to false.
API
Return value
The value returned by this util.
- The nearest scrollable ancestor, or document.scrollingElement as the document-level fallback.
Usage
Examples
Ready-to-paste usage snippets.
Find the scrollable container of a tooltip anchor