Calling the Selection.toString() method returns the text contained in the selection, e.g.:

Documentation Selection by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Variables

read onlyanchorNode:Node

Returns the Node in which the selection begins.

read onlyanchorOffset:Int

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

read onlyfocusNode:Node

Returns the Node in which the selection ends.

read onlyfocusOffset:Int

Returns 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:Bool

Returns a Boolean indicating whether the selection's start and end points are at the same position.

read onlyrangeCount:Int

Returns the number of ranges in the selection.

Methods

addRange (range:Range):Void

Throws:

null

DOMError

collapse (node:Node, offset:Int):Void

Throws:

null

DOMError

collapseToEnd ():Void

Throws:

null

DOMError

collapseToStart ():Void

Throws:

null

DOMError

containsNode (node:Node, allowPartialContainment:Bool):Bool

Throws:

null

DOMError

deleteFromDocument ():Void

Throws:

null

DOMError

extend (node:Node, offset:Int):Void

Throws:

null

DOMError

getRangeAt (index:Int):Range

Throws:

null

DOMError

modify (alter:String, direction:String, granularity:String):Void

Throws:

null

DOMError

removeAllRanges ():Void

Throws:

null

DOMError

removeRange (range:Range):Void

Throws:

null

DOMError

selectAllChildren (node:Node):Void

Throws:

null

DOMError