Everything about appendChild() | JavaScript Tutorial
The appendChild() method of the Node interface adds a node to the end of the list of children of a specified parent node.
- the
appendChild()moves it from its current position to the new position. This means that a node can’t be in two points of the document simultaneously. - The
Node.cloneNode()method can be used to make a copy of the node before appending it under the new parent. Copies made withcloneNodeare not automatically kept in sync. - Chaining does not work, due to
appendChild().like this one:
let aBlock = document.createElement('block').appendChild( document.createElement('b') );Syntax
appendChild(aChild);Parameters
aChild
Get Revive Coding’s stories in your inbox
Join Medium for free to get updates from this writer.
The node to append to the given parent node (commonly an element).
Example:
// Create a new paragraph element, and append it to the end of the document body
let p = document.createElement("p");
document.body.appendChild(p);If find difficulty for any reason please go to ref blog.




