Range.commonAncestorContainer

这篇翻译不完整。请帮忙从英语翻译这篇文章

Range.commonAncestorContainer 只读属性,返回目标节点的共有祖先节点。因而需要注意:selectNode方法中的该值为目标节点的父节点,selectNodeContents方法中的该值为其本身。

在某些跨节点的选取操作时,取得最大"公约数"的节点为commonAncestorContainer。Range.startContainer 和 Range.endContainer 相同的节点是目标节点的 共有祖先节点。

更改 Node, 请使用setStart setEnd 及这两种方法的延伸方法 Range.

语法

rangeAncestor = range.commonAncestorContainer;

示例

var range = document.createRange();

range.setStart(startNode,startOffset);
range.setEnd(endNode,endOffset);
rangeAncestor = range.commonAncestorContainer;

特别说明

Specification Status Comment
DOM
Range.commonAncestorContainer
Living Standard No change.
Document Object Model (DOM) Level 2 Traversal and Range Specification
Range.commonAncestorContainer
Obsolete Initial specification.

支持度

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
commonAncestorContainerChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support 9Opera Full support 9Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

更多

文档标签和贡献者

此页面的贡献者: faliye
最后编辑者: faliye,