Open In App

HTML DOM Range endContainer property

The endContainer property returns the Node within which the Current Range ends. This is a read-only property.

Syntax:



parentNode = range.endContainer;

Return Value:

Example: This example will show how to get the endContainer Node of the Current Range.






<!DOCTYPE html>
<html lang="en">
 
<head>
    <title>
          HTML DOM range endContainer property
      </title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <p>This is the Range Content</p>
   
    <script>
        let range = document.createRange();
        let referenceNode = document.getElementsByTagName(
                              'p').item(0);
        range.selectNode(referenceNode);
        console.log(range.endContainer);
    </script>
</body>
 
</html>

Output: In the console, we got the endContainer Node for our range.

Supported Browsers:

Article Tags :