Export (0) Print
Expand All

Range object

Specifies a general way to select content between a two boundary points.

Document Object Model (DOM) Level 2 Traversal and Range Specification, Section 2.13

Members

The Range object has these types of members:

Methods

The Range object has these methods.

MethodDescription
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.

PropertyDescription

collapsed

Retrieves whether a range is collapsed or empty.

commonAncestorContainer

Returns the deepest node in which two boundary points exist.

endContainer

Retrieves the end point node of the current range.

endOffset

Retrieves the ending boundary point relative to the startContainer in the current range.

startContainer

Retrieves the starting node of a current range.

startOffset

Retrieves the offset of the starting boundary point relative to the startContainer in the current range.

 

Standards information

 

 

Show:
© 2014 Microsoft