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:
- Returns the node within which the current range ends.
Example: This example will show how to get the endContainer Node of the Current Range.
HTML
<!DOCTYPE html><html lang="en">Â
<head>    <title>          HTML DOM range endContainer property      </title></head>Â
<body>Â Â Â Â <h1>zambiatek</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:
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Safari 1 and above
- Opera 9 and above
- Internet Explorer 9 and above
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!




