Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Range selectNode() method

  • Last Updated : 30 Jun, 2020

The selectNode() method sets the Range content to contain the Node. The start and end of the Range will be the same as the referenceNode.




  • referenceNode: The Node which sets the Range content.

Return Value: This method has no return value.

Example: This example shows how to set the content of the range using this method.

For better clarification, console logged the new range content in string text by toString() method.


<title>HTML DOM range selectNode() method</title>   
<p>This is the Range Content</p>
    let range = document.createRange();
    let referenceNode = document.getElementsByTagName('p').item(0);

Output: In console, range content can be seen.

Supported Browsers: 

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

Start Your Coding Journey Now!