DocumentOrShadowRoot.elementsFromPoint()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

elementsFromPoint()DocumentOrShadowRoot 下的一个函数,该函数返还在特定坐标点下的 HTML 元素数组。

语法

var elements = document.elementsFromPoint(x, y);

参数

x

坐标点的水平坐标值

y

坐标点的垂向坐标值

返回值

一个包含 element 对象的数组。

规范

Specification
CSSOM View Module
# dom-document-elementsfrompoint

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
elementsFromPoint

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.
Requires a vendor prefix or different name for use.
Has more compatibility info.