Represents text in an HTML element.
- Retrieves the height of the rectangle that bounds the TextRange object.
- Retrieves the distance between the left edge of the rectangle that bounds the TextRange object and the left side of the object that contains the TextRange.
- Retrieves the distance between the top edge of the rectangle that bounds the TextRange object and the top side of the object that contains the TextRange.
- Retrieves the width of the rectangle that bounds the TextRange object
- Sets or retrieves the text contained within the range.
- Returns a duplicate of the TextRange.
- Retrieves a bookmark (opaque string) that can be used with moveToBookmark to return to the same range.
- Collapses the given text range and moves the empty range by the given number of units.
- Changes the end position of the range.
- Changes the start position of the range.
- Moves to a bookmark.
- Moves the text range so that the start and end positions of the range encompass the text in the given element.
- Moves the start and end positions of the text range to the given point.
- Retrieves the parent element for the given text range.
- Pastes HTML text into the given text range, replacing any previous text and HTML elements in the range.
- Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document.
- Returns a Boolean value that indicates whether the specified command is in the indeterminate state.
- Returns a Boolean value that indicates the current state of the command.
- Returns a Boolean value that indicates whether the current command is supported on the current range.
- Returns the current value of the document, range, or current selection for the given command.
- Causes the object to scroll into view, aligning it either at the top or bottom of the window.
- Makes the selection equal to the current object.
- Sets the endpoint of one range based on the endpoint of another range.
This example changes the text of a button element to “Clicked” through the TextRange object.
Use this object to retrieve and modify text in an element, to locate specific strings in the text, and to carry out commands that affect the appearance of the text.
To retrieve a text range object, apply the createRange method to a body, button, or textArea element or an input element that has TYPE text. Modify the extent of the text range by moving its start and end positions with methods such as move and moveToElementText. Within the text range, you can retrieve and modify plain text or HTML text. These forms of text are identical except that HTML text includes HTML tags, and plain text does not.
Microsoft Developer Network: [TextRange Object Article]