setEnd method (Range)
Sets the end position of the current Range.
Note: The Range object and its setEnd method are supported in Internet Explorer from version 9.The end position of a Range is the first position in the DOM hierarchy that is after the Range.
- If the end position of a Range needs to be aligned to the start or end position of a node, the setEndBefore and setEndAfter methods can be used.
- Similarly, the setStart, setStartBefore and setStartAfter methods set the start 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 end point.|
|Required. Integer that specifies the position of the new end 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 setEnd method:
Did you find this example helpful?
User Contributed Comments