collapse method (selectionRange)
Moves the anchor and focus points of the current selectionRange object to the same, specified point.
Note: The selectionRange object and its collapse method are supported in Internet Explorer from version 9.The selectionRange object represents the current selection. In older Internet Explorer versions (and optionally in newer ones as well), use the createRange method on the selection object to get a TextRange object that represents the current selection and use the collapse method to collapse it. See the example below for details.
You can find the related objects in the Supported by objects section below.
|Required. Refers to the deepest node in the DOM hierarchy that contains the new position. Sets the anchorNode and focusNode properties to the referred node.|
Required. Integer that specifies the new position relative to the parentNode element.
If the parentNode element can have child nodes, then the offsetInsideParent parameter specifies the position of a child node in the childNodes collection of the parentNode element, else it specifies a character position in the text content of the parentNode element.This parameter sets the anchorOffset and focusOffset properties to the specified position.
This method has no return value.
Example HTML code 1:
This example illustrates the use of the collapse method:
Did you find this example helpful?
User Contributed Comments