document.elementsFromPoint(x, y) returns an array of every Element under viewport coordinates (x, y), ordered from topmost to bottommost. It works like elementFromPoint(), but gives the full stack (MDN).
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call document.elementsFromPoint. Start with this line.
JavaScript
document.elementsFromPoint(x, y)
Call
What it does
document.elementsFromPoint(x, y)
Primary signature.
document.elementsFromPoint(...)
Call with the arguments your case needs.
Built into the browser. Call elementsFromPoint(...) on document — no import required.
Library declarations
JavaScript
document.elementsFromPoint(x, y)
Parameters
Parameter
Description
x
Required. Horizontal viewport coordinate
y
Required. Vertical viewport coordinate
Return Value
Return Value
Description
*
Element[] topmost → bottommost
JavaScript Examples
Example 1 — Print the Stack
MDN-style output: local names joined with < from top to bottom.
Nest a button in a div. Both boxes cover the hit point.
Topmost is the button.stack[0] is the painted front.
Outer is still listed. Later indexes include the parent div.
Use case. Great for overlays, custom drop targets, and “what is under this?” tools.
Compatibility
Browser Support
Document.elementsFromPoint() is Baseline Widely available (MDN). It is not Deprecated, Experimental, or Non-standard.
✓ Baseline · Widely available
Document.elementsFromPoint()
Supported in every modern browser. Use when you need the full hit stack, not just the topmost node.
99%Modern browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
document.elementsFromPoint()Excellent
Bottom line: Safe everywhere. Focus on stack order (top → bottom) and whether elementFromPoint is enough for your case.
Frequently Asked Questions
MDN: Document.elementsFromPoint() returns an array of all elements at the specified coordinates (relative to the viewport), ordered from the topmost to the bottommost box.
No. MDN marks Document.elementsFromPoint() as Baseline Widely available. It is not Deprecated, Experimental, or Non-standard.
MDN: it operates similarly to elementFromPoint(), but returns every element in the stack instead of only the topmost Element.
MDN: ordered from the topmost to the bottommost box of the viewport. Index 0 is usually the same element elementFromPoint() would return.
Yes. Like elementFromPoint, use viewport coordinates such as mouse event clientX and clientY.
You get an empty array (or only root boxes, depending on the point). Always check length before reading stack[0].