Readonly
anchorThe Selection.anchorNode
read-only property returns the Node in which the selection begins.
Readonly
anchorThe Selection.anchorOffset
read-only property returns the number of characters that the selection's anchor is offset within the In the case of Selection.anchorNode being another type of node, Selection.anchorOffset
returns the number of Node.childNodes the selection's anchor is offset within the Selection.anchorNode.
Readonly
directionThe direction
read-only property of the Selection interface is a string that provides the direction of the current selection.
Readonly
focusThe Selection.focusNode
read-only property returns the Node in which the selection ends.
Readonly
focusThe Selection.focusOffset
read-only property returns the number of characters that the selection's focus is offset within the In the case of Selection.focusNode being another type of node, Selection.focusOffset
returns the number of Node.childNodes the selection's focus is offset within the Selection.focusNode.
Readonly
isThe Selection.isCollapsed
read-only property returns a boolean value which indicates whether or not there is currently any text selected.
Readonly
rangeThe Selection.rangeCount
read-only property returns the number of ranges in the selection.
Readonly
typeThe type
read-only property of the type of the current selection.
The Selection.addRange()
method adds a js-nolint addRange(range)
- range
- : A Range object that will be added to the Selection.
The Selection.collapse()
method collapses the current selection to a single point.
Optional
offset: numberThe Selection.collapseToEnd()
method collapses the selection to the end of the last range in the selection.
The Selection.collapseToStart()
method collapses the selection to the start of the first range in the selection.
The Selection.containsNode()
method indicates whether a specified node is part of the selection.
Optional
allowPartialContainment: booleanThe deleteFromDocument()
method of the js-nolint deleteFromDocument()
None.
The Selection.empty()
method removes all ranges from the selection, leaving the Selection.anchorNode and Selection.focusNode properties equal to null
and nothing selected.
The Selection.extend()
method moves the focus of the selection to a specified point.
Optional
offset: numberThe Selection.getComposedRanges()
method returns an array of StaticRange objects representing the current selection ranges, and can return ranges that potentially cross shadow boundaries.
Optional
options: GetComposedRangesOptionsThe getRangeAt()
method of the Selection interface returns a range object representing a currently selected range.
The Selection.modify()
method applies a change to the current selection or cursor position, using simple textual commands.
Optional
alter: stringOptional
direction: stringOptional
granularity: stringThe Selection.removeAllRanges()
method removes all ranges from the selection, leaving the Selection.anchorNode and Selection.focusNode properties equal to null
and nothing selected.
The Selection.removeRange()
method removes a range from a selection.
The Selection.selectAllChildren()
method adds all the children of the specified node to the selection.
The Selection.setPosition()
method collapses the current selection to a single point.
Optional
offset: number
A
Selection
object represents the range of text selected by the user or the current position of the caret.MDN Reference