-
Create Nodes
-
We can create two kind of element
- Create a Element
document.createElement('h1');
- The simple fact to create a node is not mean that we add this new node into DOM, the element is save on memory.
- Create Text
document.createTextNode('text');
- Create a Element
-
Add Nodes
parentElement.appendChild('referentNode, newNode')
- Always add a new node at end
- Always add a new node at end
parentElement.append()
doesn’t work on Internet ExplorerparentElement.insertBefore('referentNode', newNode)
- referent node have to be a child of the base node
- referent node have to be a child of the base node
parentElement.insertAdjacentElement('positionNode','newNode')
- String ways | Have securities problems
node.outerHTML(read)
node.innerHTML(write)
Curso de Manipulación del DOM
0 Comentarios
para escribir tu comentario