HTML DOM adoptNode() Method

Last Updated : 10 Aug, 2026

This DOM adoptNode() method is used to adopt a node from another document. All node types can be adopted. All child nodes along with the original node can be adopted. AdoptNode() method is used to return node objects.

Syntax

document.adoptNode(node)

Parameter Value: Any type of node is required.

Return Value: It returns a node object, representing the adopted node.

Example

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<body>
    <h1>
        <center>Geeks<button onclick="adopt()">Press</button>
        </center>
    </h1>

    <h4>Clicking on the 'Press' button will showcase adopt() method</h4>
    <p id="gfg">
        <iframe src = "https://www.geeksforgeeks.org/community/"
        </iframe>
    </p>
<!--Driver Code Ends-->

    <script>
        function adopt() {
            let frame = document.getElementsByTagName("iframe")[0];
            let h = frame.contentWindow.document.getElementsByTagName("button")[0];
            // 'h' is button type adopted node.
            let x = document.adoptNode(h);
            document.body.appendChild(x);
        }
    </script>

<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->
Comment