appendChild
appendChild is a method of the Node interface in the Document Object Model (DOM) used to insert a node as the last child of a specified parent node. It takes a single argument, a Node, and appends it to the end of the parent's child list. If the node already has a parent, it is removed from that parent before being added to the new one. The method returns the appended node.
Nodes of any type can be appended, including Element, Text, and Comment nodes, as well as DocumentFragment
Passing a value that is not a Node results in a TypeError in compliant environments.
Compatibility and usage: appendChild is part of the DOM Level 2 Core and is supported by all
Example: var parent = document.getElementById('list'); var item = document.createElement('li'); item.textContent = 'New item'; parent.appendChild(item);
- append