Range: isPointInRange() method

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 Range.isPointInRange() method returns a boolean indicating whether the given point is in the Range. It returns true if the point (cursor position) at offset within ReferenceNode is within this range.

Syntax

js
isPointInRange(referenceNode, offset)

Parameters

referenceNode

The Node to compare with the Range.

offset

The offset into Node of the point to compare with the Range.

Return value

A boolean.

Examples

js
range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
bool = range.isPointInRange(document.getElementsByTagName("p").item(0), 1);

Specifications

Specification
DOM Standard
# dom-range-ispointinrange

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
isPointInRange

Legend

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

Full support
Full support

See also