package js.html
Available on js
A Selection object represents the range of text selected by the user or the current position of the caret. To obtain a Selection object for examination or modification, call window.getSelection().
Documentation Selection by Mozilla Contributors, licensed under CC-BY-SA 2.5.
See also:
read onlyanchorNode:NodeReturns the Node in which the selection begins.
read onlyanchorOffset:IntReturns a number representing the offset of the selection's anchor within the anchorNode. If anchorNode is a text node, this is the number of characters within anchorNode preceding the anchor. If anchorNode is an element, this is the number of child nodes of the anchorNode preceding the anchor.
caretBidiLevel:Intread onlyfocusNode:NodeReturns the Node in which the selection ends.
read onlyfocusOffset:IntReturns a number representing the offset of the selection's anchor within the focusNode. If focusNode is a text node, this is the number of characters within focusNode preceding the focus. If focusNode is an element, this is the number of child nodes of the focusNode preceding the focus.
read onlyisCollapsed:BoolReturns a Boolean indicating whether the selection's start and end points are at the same position.
read onlyrangeCount:IntReturns the number of ranges in the selection.
read onlytype:StringReturns a DOMString describing the type of the current selection.
addRange(range:Range):VoidA Range object that will be added to the selection.
Throws:
null |
DOMError |
|---|
collapse(node:Node, offset:Int = 0):VoidCollapses the current selection to a single point.
Throws:
null |
DOMError |
|---|
collapseToEnd():VoidCollapses the selection to the end of the last range in the selection.
Throws:
null |
DOMError |
|---|
collapseToStart():VoidCollapses the selection to the start of the first range in the selection.
Throws:
null |
DOMError |
|---|
containsNode(node:Node, allowPartialContainment:Bool = false):BoolIndicates if a certain node is part of the selection.
Throws:
null |
DOMError |
|---|
deleteFromDocument():VoidDeletes the selection's content from the document.
Throws:
null |
DOMError |
|---|
empty():VoidThrows:
null |
DOMError |
|---|
extend(node:Node, offset:Int = 0):VoidMoves the focus of the selection to a specified point.
Throws:
null |
DOMError |
|---|
getRangeAt(index:Int):RangeReturns a Range object representing one of the ranges currently selected.
Throws:
null |
DOMError |
|---|
modify(alter:String, direction:String, granularity:String):VoidChanges the current selection.
Throws:
null |
DOMError |
|---|
removeAllRanges():VoidRemoves all ranges from the selection.
Throws:
null |
DOMError |
|---|
removeRange(range:Range):VoidRemoves a range from the selection.
Throws:
null |
DOMError |
|---|
selectAllChildren(node:Node):VoidAdds all the children of the specified node to the selection.
Throws:
null |
DOMError |
|---|
setBaseAndExtent(anchorNode:Node, anchorOffset:Int, focusNode:Node, focusOffset:Int):VoidSets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them.
Throws:
null |
DOMError |
|---|
setPosition(node:Node, offset:Int = 0):VoidThrows:
null |
DOMError |
|---|
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/js/html/Selection.html