DOM - AppendChild

1 - About

AppendChild is a node dom tree operation that adds a children node at the end of all already existing children of this node.

3 - Syntax


returnedValue = node.appendChild(Node|documentFragment)

where:

  • returnedValue is:
    • the appended child if the argument is a node
    • the empty DocumentFragment if the argument is a DocumentFragment

4 - Example

With the HTML DOM


for (var i=0;i<=3;i++){


let p = document.createElement("p");
  p.innerText = "Lorem Ipsom "+i;

  • Append it to the body

document.body.appendChild(p);
}

  • Result:


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap