JS DOM: Create Element, Clone
-
document.createElement(tagName)
-
Create a new tagName element. Return it.
γsee Create and Insert HTML Elementγ
-
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 JS DOM: textContent, innerHTML, innerText, nodeValueγ
Basic DOM Element Methods
- JS DOM: Node, Node Type, Element
- JS DOM: Get Element by ID, Name, Class etc
- JS DOM: Get Element Parent, Child, Sibling
- JS DOM: NodeList vs HTMLCollection
- JS DOM: Iterate HTMLCollection
- JS DOM: Element Attribute Methods
- JS DOM: List, Add, Remove Class Attribute
- JS DOM: Create Element, Clone
- JS DOM: Insert, Remove, Replace Element
- JS DOM: Change Element Content
- JS DOM: Add, Remove Event Handler