Range.intersectsNode()

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

Range.intersectsNode() 方法返回一个布尔值,表明其给定的 Node 节点是否与Range的范围相交

Syntax

bool = range.intersectsNode( referenceNode )

Parameters

referenceNode
Range做比较的Node节点

Example

var range = document.createRange();

range.selectNode(document.getElementsByTagName("div").item(0));
var bool = range.intersectsNode(document.getElementsByTagName("p").item(0));

Specification

Specification Status Comment
DOM
Range.intersectNode()
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
intersectsNode
Experimental
Chrome Full support YesEdge Full support 17Firefox Full support 17IE No support NoOpera Full support 15Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 19Opera Android Full support 14Safari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

See also