If you remove a node and then insert another one at the same place, the replaceChild() method saves you a bit of coding. You provide the new and the old node, and JavaScript does the rest for you. Remember that you have to call this method from the parent element of the old and the new node! Replacing Nodes (replace.html)
The preceding code replaces the first child (node) of the list with a new node. |