endOffset property (Range)
Returns an integer that specifies the end position of the current Range relative to the endContainer element.
Note: The Range object and its endOffset property are supported in Internet Explorer from version 9.If the node referred to by the endContainer property is a TextNode, CDATASection or CommentNode, then the endOffset property returns a character position in the text content of the referred node. For other node types, the returned value is an index into the childNodes collection of the node.
Note that the end point is not part of the Range (it is the first position after), therefore the value returned by the endOffset property can be equal to the length of the text content or childNodes collection of the node referred to by the endContainer property.
Similarly, you can get the start point of a Range with the startContainer and startOffset properties.
You can find the related objects in the Supported by objects section below.
This property is read-only.
Integer that represents the end position.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the endOffset property:
Did you find this example helpful?
User Contributed Comments