Web APIs
Element.append()
append inserts nodes or strings after existing children. Inserting a node already in a tree moves it rather than duplicating it. cloneNode is needed for a separate copy.
Formal Syntax & Structure
javascript syntaxjavascript
element.append(...nodesOrStrings)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| nodesOrStrings | Node | string | Zero or more nodes or strings to insert. |
Return Value
undefined
No result value.
Working Example
Example Snippetjavascript
const a=document.createElement("div"),b=document.createElement("div"),p=document.createElement("p");a.append(p);b.append(p);console.log(a.children.length,b.children.length);