You are here: Reference > JavaScript > client-side > selection and ranges > methods > expand (TextRange)
expand method (TextRange)
Expands the contents of the TextRange from the insertion point by a character, sentence or word.
If you need to move only the start or end point of a TextRange, use the moveStart and moveEnd methods.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. String that specifies the type of unit to expand by.
One of the following values:
|
Return value:
Boolean. One of the following values:
The range was not expanded. | |
The range was successfully expanded. |
Example HTML code 1:
This example illustrates the use of the expand method:
|
||||
<head> <script type="text/javascript"> function SelectWholeWords () { if (document.selection) { // Internet Explorer var myRange = document.selection.createRange (); myRange.expand ("word"); myRange.select (); } } </script> </head> <body> Some text for selection. <br /><br /> <button onclick="SelectWholeWords ()">Select whole words!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments