DocumentOrShadowRoot.elementsFromPoint()

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

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

语法

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

参数

x
坐标点的水平坐标值
y
坐标点的垂向坐标值

返回值

一个包含 element 对象的数组.

其他说明

Specification Status Comment
Shadow DOM
elementsFromPoint()
Obsolete Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
elementsFromPoint
Experimental
Chrome Full support 53
Notes
Full support 53
Notes
Notes Before Chrome 66, this method returned null when the element was a child of a host node. See issue 759947.
Edge Full support 12
Notes Alternate Name
Full support 12
Notes Alternate Name
Notes Returns a NodeList instead of an array. See the MSDN documentation. Returns null when the point provided has no elements beneath it (e.g., when given a point outside the document).
Alternate Name Uses the non-standard name: msElementsFromPoint
Firefox Full support 63IE Full support 10
Notes Alternate Name
Full support 10
Notes Alternate Name
Notes Returns a NodeList instead of an array. See the MSDN documentation. Returns null when the point provided has no elements beneath it (e.g., when given a point outside the document).
Alternate Name Uses the non-standard name: msElementsFromPoint
Opera Full support 40Safari Full support 12WebView Android Full support 53
Notes
Full support 53
Notes
Notes Before WebView 66, this method returned null when the element was a child of a host node. See issue 759947.
Chrome Android Full support 53
Notes
Full support 53
Notes
Notes Before Chrome 66, this method returned null when the element was a child of a host node. See issue 759947.
Firefox Android Full support 63Opera Android Full support 41Safari iOS Full support 12Samsung Internet Android Full support 6.0

Legend

Full support  
Full support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
Uses a non-standard name.
Uses a non-standard name.