Name

expand( ) — NN n/a IE 4 DOM n/a

Synopsis

expand(unit)

Expands the current text range to encompass the textual unit passed as a parameter. For example, if someone selects some characters from a document, you can create the range and expand it to encompass the entire sentence in which the selection takes place:

var rng = document.selection.createRange( )
rng.expand("sentence")

If the starting range extends across multiple units, the expand( ) method expands the range outward to the next nearest unit.

Returned Value

Boolean value: true if method is successful; false if unsuccessful.

Parameters

unit

A case-insensitive string value of the desired unit: character | word | sentence | textedit. The textedit value expands the range to the entire original range.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.