You are here: Reference > JavaScript > client-side > selection and ranges > properties

Selection and range properties in JavaScript

TextRange properties:
Property Support Description
boundingHeight
(TextRange)
Returns an integer value that specifies the height of the rectangle that bounds the current TextRange object, in pixels.
boundingLeft
(TextRange)
Returns an integer value that specifies the left coordinate of the rectangle that bounds the current TextRange object, in pixels.
boundingTop
(TextRange)
Returns an integer value that specifies the top coordinate of the rectangle that bounds the current TextRange object, in pixels.
boundingWidth
(TextRange)
Returns an integer value that specifies the width of the rectangle that bounds the current TextRange object, in pixels.
htmlText
(TextRange)
Returns the HTML source that belongs to a TextRange object as a string.
text
(TextRange)
10.5
Sets or retrieves a string that specifies the text within a TextRange object.
Range properties:
Property Support Description
collapsed
(Range)
9
Returns a Boolean value that indicates whether the start and end points of the current Range are in the same position.
commonAncestorContainer
(Range)
9
Returns a reference to the deepest node in the DOM hierarchy that contains the entire Range object.
endContainer
(Range)
9
Returns a reference to the deepest node in the DOM hierarchy that contains the end point of the current Range object.
endOffset
(Range)
9
Returns an integer that specifies the end position of the current Range relative to the endContainer element.
startContainer
(Range)
9
Returns a reference to the deepest node in the DOM hierarchy that contains the start point of the current Range object.
startOffset
(Range)
9
Returns an integer that specifies the start position of the current Range relative to the startContainer element.
Selection properties:
Property Support Description
selection
(document)
10.5
Represents the currently selected part of the document.
type
(selection)
10.5
Returns a string value that identifies the content type of the current selection.
TextRanges properties:
Property Support Description
length
(TextRanges)
Returns an integer that specifies the number of objects in the current collection.
ControlRange properties:
Property Support Description
length
(controlRange)
Returns an integer that specifies the number of objects in the current collection.
SelectionRange properties:
Property Support Description
anchorNode
(selectionRange)
9
Returns a reference to the node where the selection begins.
anchorOffset
(selectionRange)
9
Returns the start position of the selection relative to the anchor node.
focusNode
(selectionRange)
9
Returns a reference to the element where the selection ends.
focusOffset
(selectionRange)
9
Returns the end position of the selection relative to the focus node.
isCollapsed
(selectionRange)
9
Returns a Boolean value that indicates whether the anchor and focus points of the current selectionRange object are in the same position.
rangeCount
(selectionRange)
9
Returns the number of Range objects that belong to the current selection.
User Contributed Comments

Post Content

Post Content