setStart method (Range)
Sets the start position of the current Range.
Note: The Range object and its setStart method are supported in Internet Explorer from version 9.The start position of a Range is the first position in the DOM hierarchy that is contained by the Range. If the start position of a Range needs to be aligned to the start or end position of a node, the setStartBefore and setStartAfter methods can be used.
- Similarly, the setEnd, setEndBefore and setEndAfter methods set the end position of a Range.
- If you want to align the boundary points of a Range to the start and end points of an element or its contents, use the selectNode or selectNodeContents method.
- The boundary points of a Range object can be retrieved with the startContainer, startOffset, endContainer and endOffset properties.
You can find the related objects in the Supported by objects section below.
|Required. Reference to the deepest node in the DOM hierarchy that contains the new start point.|
Required. Integer that specifies the position of the new start point relative to the node element.
If the node element can have child nodes, then the offsetInsideNode parameter specifies the position of a child node in the childNodes collection of the node element, else it specifies a character position in the text content of the node element.
This method has no return value.
Example HTML code 1:
This example illustrates the use of the setStart method:
Did you find this example helpful?
User Contributed Comments