Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Range setEndAfter() Method

  • Last Updated : 07 Jul, 2020

The Range setEndAfter() method is used to set 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 is used and its content is included in the range.


range.setEndAfter( refNode );


  • refNode: The Node that sets the ending of the range.

Return Value: This method does not return any value.

Example: This example describes how to set the ending position of the range. Also in this example, we have used setStartBefore() method to set the starting of the range. The end reference node is the second <i> element of the document.


<!DOCTYPE html>
    The range will start from 1st
    element in italics <i> RangeStart</i>
    and end at 2nd italics element
        var range = document.createRange();
        var startNode = document
        var endNode = document

Output: In console, the created range can be seen.

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!