The cloneRange() method is used to make a clone of original range and returns that cloned Range object it into a new variable.
Note: Change in either Range does not affect the other Range.
Syntax:
newRange = originalRange.cloneRange();
Parameters: This method does not accept any parameter.
Return Value: This method returns the newly created range object.
Example: In this example, a range is cloned. For more clarification of cloned range, a cloned range is converted into string text using toString() method and showed that cloned range object in the console.
HTML
<!DOCTYPE html><html>Â
<head>    <title>        HTML DOM range cloneRange() method    </title></head>Â
<body>Â Â Â Â <h1>neveropen</h1>Â
     <p>This is the range.</p>Â
Â
    <script>        originalRange = document.createRange();                 originalRange.selectNode(document            .getElementsByTagName("p").item(0));                     clonedRange = originalRange.cloneRange();        console.log(clonedRange);        console.log(clonedRange.toString());    </script></body>Â
</html> |
Output: In console, the new cloned range object can be seen.
Supported Browsers:Â
- Google Chrome 1
- Edge 12
- Firefox 1
- Internet Explorer 9
- Safari 1
- Opera 9

