JS: Create Element, Clone
-
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.
-
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.
-
node.innerHTML
- The content of node as string. You can read or set this value. [see DOM: textContent, innerHTML, innerText, nodeValue]
Basic DOM Element Methods
- JS: What is Node, Node Type, Element
- JS: Get Element by ID, Name, Class etc
- JS: Iterate HTML Elements
- JS: Element Attribute Methods
- JS: List, Add, Remove Class Attribute
- JS: Get Element Parent, Child, Sibling, Navigate DOM Tree
- JS: Create Element, Clone
- JS: Insert, Remove, Replace Element
- JS: Change Element's Content
- JS: Add, Remove Event Handler