Range.endOffset

只读属性 Range.endOffset 返回代表 Range 结束位置在 Range.endContainer 中的偏移值的数字。

如果 endContainerNode 类型为 Text, Comment,或 CDATASection,偏移值是 endContainer 节点开头到 Range 末尾的总字符个数。对其他类型的 NodeendOffsetendContainer 开头到 Range 末尾的总 Node 个数。如需修改 endOffset 的值, 使用 Range.setEnd 方法。

语法

endRangeOffset = range.endOffset;

示例

var range = document.createRange();

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

规范

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

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
endOffsetChrome 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 Full support Yes

Legend

Full support  
Full support

参见