HTML DOM Document adoptNode() method
- Previous Page addEventListener()
- Next Page anchors
- Go to the Previous Level HTML DOM Documents
Definition and usage
adoptNode()
The method adopts a node from another document.
Description
The adopted node can be of any type.
Any child nodes (descendants) of the adopted node are also adopted.
The original node (with child nodes) will be removed from the other document.
See also:
Example
Adopt the first <h1> element that appears in the iframe (another document):
const frame = document.getElementById("myFrame"); const h1 = frame.contentWindow.document.getElementsByTagName("H1")[0]; const node = document.adoptNode(h1);
Syntax
document.adoptNode(node)
Parameter
Parameter | Description |
---|---|
node | Required. A node from another document. It can be any node type. |
Return value
Type | Description |
---|---|
Node | Adopted node. |
Browser support
document.adoptNode
It is a DOM Level 3 (2004) feature.
All browsers fully support it:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | 9-11 | Support | Support | Support | Support |
- Previous Page addEventListener()
- Next Page anchors
- Go to the Previous Level HTML DOM Documents