Range:endOffset 属性
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
Range.endOffset
只读属性返回一个数字,表示 Range.endContainer
在 Range
中的结束位置。
如果 endContainer
是 Text
、Comment
或 CDATASection
类型的 Node
,那么偏移量是从 endContainer
的起始位置到 Range
边界点之间的字符数。对于其他的 Node
类型,endOffset
是从 endContainer
的起始位置到 Range
边界点之间的子节点数。此属性为只读。要更改 Range
的 endOffset
值,请使用 Range.setEnd
方法。
值
数字。
示例
js
const range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
endRangeOffset = range.endOffset;
规范
Specification |
---|
DOM # ref-for-dom-range-endoffset① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
endOffset |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.