Skip to content
Related Articles

Related Articles

HTML DOM Range selectNodeContents() Method

Improve Article
Save Article
Like Article
  • Last Updated : 29 Jun, 2020

The selectNodeContents() method sets the Range that contain the contents of a Node.

The startOffset is 0 every time, and the endOffset can be the number of child Nodes or number of characters contained in the reference Node.




  • referenceNode : The Node whose contents will set 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 of the example , console logged the range content in string text by toString() method.


<!DOCTYPE html>
        HTML DOM range selectNodeContents() method
    <div>This is the Range Content</div>
        var range;
        range = document.createRange();

Output: In console, range can be seen.

Supported Browsers: The browsers supported by DOM selectNodeContents() method are listed below:

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

Start Your Coding Journey Now!