Range object
Specifies a general way to select content between a two boundary points.
![]() |
Members
The Range object has these types of members:
Methods
The Range object has these methods.
| Method | Description |
|---|---|
| cloneContents |
Returns a document fragment containing the nodes of a range. If any nodes are partially selected, their start or end nodes are included. |
| cloneRange |
Returns a new range with boundary points that are equal to the original range. |
| collapse |
Collapses (or removes) a range by moving the insertion point to the beginning or end of the current range. |
| compareBoundaryPoints |
Compares two ranges by comparing their boundary points. |
| createContextualFragment |
The createContextualFragment() method enables you to parse a string of HTML into a DocumentFragment using the starting node of a DOM Range as the parsing context. |
| deleteContents |
Removes all contents within a selected range. |
| detach |
Removes or detaches an object and associated resources. |
| extractContents |
Removes the contents of a range from a document or document fragment and puts it a new document fragment. |
| insertNode |
Inserts a node into the start of a Range object. |
| selectNode |
Selects a range node and all of its contents. |
| selectNodeContents |
Selects the contents within a node in a range. |
| setEnd |
Sets the end point of the range. |
| setEndAfter |
Sets the end of a range to a point after a specific node. |
| setEndBefore |
Sets the end of the range to a point before a specific node. |
| setStart |
Sets the starting point of a range. |
| setStartAfter |
Sets the starting point of the range to a point after a specific node. |
| setStartBefore |
Sets the start point of a range to a point before a specific node. |
| surroundContents |
Moves the contents of a Range to a new parent node, placing the new parent node at the start position of the Range. |
| toString |
Returns the contents of a Range as a string. This string contains only the data characters, no markup. |
Properties
The Range object has these properties.
| Property | Description |
|---|---|
|
Retrieves whether a range is collapsed or empty. | |
|
Returns the deepest node in which two boundary points exist. | |
|
Retrieves the end point node of the current range. | |
|
Retrieves the ending boundary point relative to the startContainer in the current range. | |
|
Retrieves the starting node of a current range. | |
|
Retrieves the offset of the starting boundary point relative to the startContainer in the current range. |
Standards information
