selectNodeContents method (Range)
Aligns the start and end points of the current Range object to the contents of the specified element.
Note: The Range object and its selectNodeContents method are supported in Internet Explorer from version 9.
- The boundary points can be retrieved with the startContainer, startOffset, endContainer and endOffset properties.
- To align the boundary points to a node instead of its contents, use the selectNode method.
- If you want to modify the start or end point only, use the (setStart, setStartBefore, setStartAfter) and the ((setEnd, setEndBefore, setEndAfter)) methods.
You can find the related objects in the Supported by objects section below.
|Required. Reference to a node to align to.|
This method has no return value.
The selectNodeContents (node) method is equivalent to setStart (node, 0); setEnd (node, len); where the value of the len parameter is the length of the node's text content (when the node is a TextNode, CDATASection or CommentNode) or the length of the childNodes collection that belongs to the node (in other cases).
Example HTML code 1:
This example illustrates the use of the selectNodeContents method:
Did you find this example helpful?
User Contributed Comments