Selection: anchorOffset 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

Selection.anchorOffset 只讀屬性返回當選區的錨點位於 TextCDATASectionComment 型別的 Selection.anchorNode 中時,錨點在該節點內的字元偏移量。

Selection.anchorNode 是其他型別的節點時,Selection.anchorOffset 返回錨點在該 Selection.anchorNode 中的 Node.childNodes 偏移量。

這個數字是從零開始計數的。如果選區從 Selection.anchorNode 的第一個字元開始,則返回 0

一個數字。

規範

規範
Selection API
# dom-selection-anchoroffset

瀏覽器相容性

另見