HTML DOM Range setEndBefore() method
The Range setEndBefore() method sets the end position of a Range relative to another Node. An element used to set the ending point range is referenceNode element. In this method the reference element used and its content is not included in the range.
- referenceNode element: The Node which the sets the ending of the range.
Return Value: This method has no return value.
Example: This example will show how to set the ending position of the range using setEndBefore() method. Also in this example, I had used setStartAfter() method to set the starting of the range. The end reference node here is the second <i> element of the document.
For reference, i had also console logged the range in the text to make it clear.
Output: In console, range made with startOffset and endOffset can be seen.
- Google Chrome