Selection
Module: JavaScript DOM API
The navigator of the view.
#include <Selection.idl>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| void | removeAllRanges() Removes all ranges from the selection. |
| void | empty() Clear the selection. This is an alias for removeAllRanges(). |
| void | setBaseAndExtent(Node anchorNode, unsigned long anchorOffset, Node focusNode, unsigned long focusOffset) Sets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them. |
| DOMString | toString() Returns a string currently being represented by the selection object, i.e. the currently selected text. |
Public Attributes
Section titled “Public Attributes”| Name | |
|---|---|
| readonly attribute Node | anchorNode Returns the Node in which the selection begins. Can return null if selection never existed in the document. |
| readonly attribute unsigned long | anchorOffset Returns a number representing the offset of the selection’s anchor within the anchorNode. |
| readonly attribute Node | focusNode Returns the Node in which the selection ends. Can return null if selection never existed in the document. |
| readonly attribute unsigned long | focusOffset Returns a number representing the offset of the selection’s anchor within the focusNode. |
Public Functions Documentation
Section titled “Public Functions Documentation”function removeAllRanges
Section titled “function removeAllRanges”void removeAllRanges()Removes all ranges from the selection.
function empty
Section titled “function empty”void empty()Clear the selection. This is an alias for removeAllRanges().
function setBaseAndExtent
Section titled “function setBaseAndExtent”void setBaseAndExtent( Node anchorNode, unsigned long anchorOffset, Node focusNode, unsigned long focusOffset)Sets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them.
function toString
Section titled “function toString”DOMString toString()Returns a string currently being represented by the selection object, i.e. the currently selected text.
Public Attributes Documentation
Section titled “Public Attributes Documentation”variable anchorNode
Section titled “variable anchorNode”readonly attribute Node anchorNode;Returns the Node in which the selection begins. Can return null if selection never existed in the document.
variable anchorOffset
Section titled “variable anchorOffset”readonly attribute unsigned long anchorOffset;Returns a number representing the offset of the selection’s anchor within the anchorNode.
variable focusNode
Section titled “variable focusNode”readonly attribute Node focusNode;Returns the Node in which the selection ends. Can return null if selection never existed in the document.
variable focusOffset
Section titled “variable focusOffset”readonly attribute unsigned long focusOffset;Returns a number representing the offset of the selection’s anchor within the focusNode.
© 2026 Coherent Labs. All rights reserved.