JS DOM: Create Element, Clone
Create element
-
document.createElement(tagName) -
Create a new tagName element. Return it.
-
document.createTextNode(str) -
Create a new text node with the node value of string str.
Clone node
-
node.cloneNode(includeChildNodes) -
- Return a copy of node.
- If includeChildNodes is true, include all child nodes.
- Default to false.
🛑 warning: the cloned node have the same ID attribute, if the original has an ID. You should change it after cloning.
Get innerhtml
-
node.innerHTML -
- The content of node as string.
- You can read or set this value. [see JS DOM: innerHTML, textContent, innerText, nodeValue]