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 属于 Text、CDATASection 或 Comment 类型时,返回选区锚点在该节点内的字符偏移量。
当 Selection.anchorNode 为其他类型的节点时,Selection.anchorOffset 返回锚点在该 Selection.anchorNode 内偏移的 Node.childNodes 数量。
这个数字从零开始计数。如果选区从 Selection.anchorNode 的第一个字符开始,则返回 0。