此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Selection:anchorOffset 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

Selection.anchorOffset 只读属性在 Selection.anchorNode 属于 TextCDATASectionComment 类型时,返回选区锚点在该节点内的字符偏移量。

Selection.anchorNode 为其他类型的节点时,Selection.anchorOffset 返回锚点在该 Selection.anchorNode 内偏移的 Node.childNodes 数量。

这个数字从零开始计数。如果选区从 Selection.anchorNode 的第一个字符开始,则返回 0

一个数字。

规范

Specification
Selection API
# dom-selection-anchoroffset

浏览器兼容性

参见