Range
interface represents a fragment of a document that can contain nodes and parts of text nodes.Document.createRange()
method. Range objects can also be retrieved by using the getRangeAt()
method of the Selection
object or the caretRangeFromPoint()
method of the Document
object.Range()
constructor available.Returns the deepest Node
that contains the startContainer
and endContainer
nodes.
SuperNode
A Boolean value which is true
if the range is collapsed. A collapsed range is one whose start position and end position are the same, resulting in a zero-character-long range.
Promise<boolean>
The DOM Node
in which the end of the range, as specified by the endOffset
property, is located.
SuperNode
An integer value indicating the offset, in characters, from the beginning of the node's contents to the beginning of the range represented by the range object. This value must be less than the length of the endContainer
node.
Promise<number>
The DOM Node
in which the beginning of the range, as specified by the startOffset
property, is located.
SuperNode
An integer value indicating the offset, in characters, from the beginning of the node's contents to the last character of the contents referred to by the range object. This value must be less than the length of the node indicated in startContainer
.
Promise<number>
Returns a DocumentFragment
copying the nodes of a Range
.
DocumentFragment
Returns a Range
object with boundary points identical to the cloned Range
.
Range
Collapses the Range
to one of its boundary points.
boolean
. A boolean
value: true
collapses the Range
to its start, false
to its end. If omitted, it defaults to false
.Promise<void>
Compares the boundary points of the Range
with another Range
.
number
. A constant describing the comparison method: Range.END_TO_END
compares the end boundary-point of *sourceRange* to the end boundary-point of Range
.Range.END_TO_START
compares the end boundary-point of *sourceRange* to the start boundary-point of Range
.Range.START_TO_END
compares the start boundary-point of *sourceRange* to the end boundary-point of Range
.Range.START_TO_START
compares the start boundary-point of *sourceRange* to the start boundary-point of Range
.If the value of the parameter is invalid, a DOMException
with a NotSupportedError
code is thrown.
Range
. A Range
to compare boundary points with the range.Promise<number>
Returns -1, 0, or 1 indicating whether the point occurs before, inside, or after the Range
.
Node
. The Node
to compare with the Range
.number
. An integer greater than or equal to zero representing the offset inside the referenceNode.Promise<number>
Returns a DocumentFragment
created from a given string of code.
string
. Text that contains text and tags to be converted to a document fragment.DocumentFragment
Removes the contents of a Range
from the Document
.
Promise<void>
Releases the Range
from use to improve performance.
Promise<void>
Moves contents of a Range
from the document tree into a DocumentFragment
.
DocumentFragment
Returns a DOMRect
object which bounds the entire contents of the Range
; this would be the union of all the rectangles returned by range.getClientRects()
.
DOMRect
Returns a list of DOMRect
objects that aggregates the results of Element.getClientRects()
for all the elements in the Range
.
DOMRectList
Insert a Node
at the start of a Range
.
Node
. The Node
to insert at the start of the range
.Promise<void>
Returns a boolean
indicating whether the given node intersects the Range
.
Node
. The Node
to compare with the Range
.Promise<boolean>
Returns a boolean
indicating whether the given point is in the Range
.
Node
. The Node
to compare with the Range
.number
. The offset into Node
of the point to compare with the Range
.Promise<boolean>
Sets the Range
to contain the Node
and its contents.
Node
. The Node
to select within a Range
.Promise<void>
Sets the Range
to contain the contents of a Node
.
Node
. The Node
whose contents will be selected within a Range
.Promise<void>
Sets the end position of a Range
.
Node
. The Node
inside which the Range
should end.number
. An integer greater than or equal to zero representing the offset for the end of the Range
from the start of endNode
.Promise<void>
Sets the end position of a Range
relative to another Node
.
Node
. The Node
to end the Range
after.Promise<void>
Sets the end position of a Range
relative to another Node
.
Node
. The Node
to end the Range
before.Promise<void>
Sets the start position of a Range
.
Node
. The Node
where the Range
should start.number
. An integer greater than or equal to zero representing the offset for the start of the Range
from the start of startNode
.Promise<void>
Sets the start position of a Range
relative to another Node
.
Node
. The Node
to start the Range
after.Promise<void>
Sets the start position of a Range
relative to another Node
.
Node
. The Node
before which the Range
should start.Promise<void>
Moves content of a Range
into a new Node
.
Node
. A Node
with which to surround the contents.Promise<void>
Returns the text of the Range
.
Promise<string>