Sitemap
Revive Coding

Revive Coding

Revive Coding is a place where you learn Web Development. Here we teach you, art of becoming Full Stack Web Developer and ready for your Dream Job.

Everything about appendChild() | JavaScript Tutorial

Jul 9, 2022

--

The appendChild() method of the Node interface adds a node to the end of the list of children of a specified parent node.

  • theappendChild() 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 with cloneNode are 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.

--

--

Revive Coding

Written by Revive Coding

Revive Coding is a place where you learn Web Development. Here we teach you, art of becoming Full Stack Web Developer and ready for your Dream Job.