Open In App

HTML DOM Range startContainer property

Last Updated : 14 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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: 

  • Returns the node within which the current range starts.

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

HTML




<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: 

  • 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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads