This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

setEnd

Summary

Sets the end point of the range.

Method of dom/Rangedom/Range

Syntax

var result = range.setEnd(/* see parameter list */);

Parameters

endNode

Data-type
DOM Node

A node in the document hierarchy.

offset

Data-type
Number

Specifies the offset value for the end point.

Return Value

Returns an object of type NumberNumber

Type: HRESULT

This method can return one of these values.

Return codeDescription
S_OKThe operation completed successfully.
InvalidStateErrordetach has been invoked on the object.
W3Exception_DOM_INDEX_SIZE_ERRoffset is negative or greater than the number of child units in refNode.

Examples

var range = document.createRange();
var endNode = document.getElementsByTagName("p").item(3);
var endOffset = document.getElementsByTagName("p").item(3).childNodes.length;
range.setEnd(endNode,endOffset);

Syntax

range.setEnd(endNode, endOffset);

Standards information

Related specifications

DOM
Living Standard

Attributions