Range.isPointInRange()

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

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

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

BCD tables only load in the browser

See also