AbstractRange: endOffset property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

The endOffset property of the AbstractRange interface returns the offset into the end node of the range's end position.

To change the end position, use the Range.setEnd() method or a similar one.

Value

An integer value indicating the number of characters into the Node indicated by endContainer at which the final character of the range is located.

If the endContainer is a Node of type Text, Comment, or CDATASection, then the offset is the number of characters from the start of the endContainer to the boundary point of the range. For other Node types, the endOffset is the number of child nodes between the start of the endContainer and the boundary point of the range.

Example

js
const range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);

const endRangeOffset = range.endOffset;

Specifications

Specification
DOM
# ref-for-dom-range-endoffset①

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
endOffset
Chrome – Full support
Chrome 90 (Release date: 2021-04-13)
footnote Full support
Edge – No support
Edge 18 – 18 (Release date: 2018-10-02)
footnote Removed in 79 and later
Edge – Full support
Edge 90 (Release date: 2021-04-15)
footnote Full support
Firefox – Full support
Firefox 69 (Release date: 2019-09-03)
footnote Full support
Opera – Full support
Opera 76 (Release date: 2021-04-28)
footnote Full support
Safari – Full support
Safari 14.1 (Release date: 2021-04-26)
footnote Full support
Chrome Android – Full support
Chrome Android 90 (Release date: 2021-04-13)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Opera Android – Full support
Opera Android 64 (Release date: 2021-05-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Samsung Internet – Full support
Samsung Internet 15 (Release date: 2021-08-13)
footnote Full support
WebView Android – Full support
WebView Android 90 (Release date: 2021-04-13)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14.5 (Release date: 2021-04-26)
footnote Full support

Legend

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

Full support
Full support
Has more compatibility info.