Object: Range
The Range object represents a range of content between two boundary points, a start point and an end point, in a Document, DocumentFragment, or Attr node.
You can create a Range object by using Document.createRange. You can retrieve a Range object by using Selection.getRangeAt.
Range properties
|
Property name |
Type |
Description |
Status |
Support level |
Availability |
|---|---|---|---|---|---|
|
boolean |
Returns true if the start point and end point of the range are the same. |
read-only |
DOM 2 Range |
4.7.1 or later |
|
|
Returns the deepest node that contains the startContainer and endContainer nodes. |
read-only |
DOM 2 Range |
4.7.1 or later |
||
|
Returns the node that contains the end point of the range. |
read-only |
DOM 2 Range |
4.7.1 or later |
||
|
int |
Returns a number that represents the end point of the range within the endContainer node. |
read-only |
DOM 2 Range |
4.7.1 or later |
|
|
Returns the node that contains the start point of the range. |
read-only |
DOM 2 Range |
4.7.1 or later |
||
|
int |
Returns a number that represents the start point of the range within the startContainer node. |
read-only |
DOM 2 Range |
4.7.1 or later |
Range methods
|
Method name |
Description |
Support level |
Availability |
|---|---|---|---|
|
Duplicates the contents of a specified range. |
DOM 2 Range |
4.7.1 or later |
|
|
Creates a new Range object with the same start point and end point as the specified range. |
DOM 2 Range |
4.7.1 or later |
|
|
Collapses a range onto its start point or end point. |
DOM 2 Range |
4.7.1 or later |
|
|
Compares the start points and end points of two ranges. |
DOM 2 Range |
4.7.1 or later |
|
|
Deletes the contents of the range from the Document or DocumentFragment node. |
DOM 2 Range |
4.7.1 or later |
|
|
Immediately releases the Range object from the object model. |
DOM 2 Range |
4.7.1 or later |
|
|
Extracts the entire contents of the range from a Document or DocumentFragment node and moves it to a new DocumentFragment object. |
DOM 2 Range |
4.7.1 or later |
|
|
Inserts a new node at the start of the range. |
DOM 2 Range |
4.7.1 or later |
|
|
Populates the range with a specified node and its contents. |
DOM 2 Range |
4.7.1 or later |
|
|
Populates the range with the contents of a specified node. |
DOM 2 Range |
4.7.1 or later |
|
|
Sets the end point of the range. |
DOM 2 Range |
4.7.1 or later |
|
|
Sets the end point of a range at a position that is after the specified node. |
DOM 2 Range |
4.7.1 or later |
|
|
Sets the end point of a range at a position that is before the specified node. |
DOM 2 Range |
4.7.1 or later |
|
|
Sets the start point of the range. |
DOM 2 Range |
4.7.1 or later |
|
|
Sets the start point of a range at a position that is after the specified node. |
DOM 2 Range |
4.7.1 or later |
|
|
Sets the start point of a range at a position that is before the specified node. |
DOM 2 Range |
4.7.1 or later |
|
|
Moves the contents of the range to a new node object, and inserts the new node at the start point of the range. |
DOM 2 Range |
4.7.1 or later |
|
|
Returns the contents of the range as a string. |
DOM 2 Range |
4.7.1 or later |