Selection: anchorOffset property

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.

The Selection.anchorOffset read-only property returns the number of characters that the selection's anchor is offset within the Selection.anchorNode if said node is of type Text, CDATASection or Comment.

In the case of Selection.anchorNode being another type of node, Selection.anchorOffset returns the number of Node.childNodes the selection's anchor is offset within the Selection.anchorNode.

This number is zero-based. If the selection begins with the first character in the Selection.anchorNode, 0 is returned.

Value

A number.

Specifications

Specification
Selection API
# dom-selection-anchoroffset

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
anchorOffset

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also