The selectAllChildren() method adds all the children of the specified node to the current selection.
Syntax:
selection.selectAllChildren( parentNode )
Parameters:
- parentNode: The node whose children are to be selected.
Example: In this example, all the child elements of the parent div will get selected on the button click using this method.
HTML
<!DOCTYPE html><html>Â
<head>Â Â Â Â <title>neveropen</title></head>Â
<body>    <main>        <h1>neveropen</h1>    </main>    <div>        <p>child 1</p>        <p>child 2</p>        <p>child 3</p>    </div>    <button onclick="select()">        click    </button>Â
    <script>        const pNode = document            .querySelector('div');        function select() {            window.getSelection()                .selectAllChildren(pNode);        };    </script></body>Â
</html> |
Output: Click the button to select the child node of the parent div:Â
Supported Browsers: The browsers supported by the selectAllChildren() method are listed below:
- Google Chrome
- Edge
- Firefox
- Opera
- Safari
- Internet Explorer.

