web api instance method
Range: isPointInRange() method
The isPointInRange() method of the Range interface determines whether a specified point is within the Range. The point is specified by a reference node and an offset within that node. It is equivalent to calling comparePoint() and checking if the result is 0.
Syntax
isPointInRange(referenceNode, offset)
Parameters
referenceNode- : The
Nodethat theoffsetis relative to.
- : The
offset- : An integer greater than or equal to zero describing the position inside
referenceNodeof the point to be checked. IfreferenceNodeis aNodeof typeText,Comment, orCDATASection, thenoffsetis the number of characters from the start ofreferenceNode. For otherNodetypes,offsetis the number of child nodes from the start of thereferenceNode.
- : An integer greater than or equal to zero describing the position inside
Return value
A boolean.
Examples
const text = new Text("0123456789");
const thisRange = new Range();
thisRange.setStart(text, 1);
thisRange.setEnd(text, 6);
thisRange.isPointInRange(text, 3); // true
thisRange.isPointInRange(text, 0); // false
thisRange.isPointInRange(text, 6); // true
thisRange.isPointInRange(text, 7); // false
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.