Open In App

HTML DOM Range startContainer property

The startContainer property returns the Parent Node within which the Current Range starts. This is a read only property.

Syntax:



ParentNode = range.startContainer;

Return Value: 

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






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

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

Supported Browsers: 

Article Tags :