Replacing Element in JavaScript
Replacing Element
For replacing elements, we use the method replaceChild(). It takes two parameters. The first one is newNode and the second is an old node.
Syntax:-
parent.replaceChild(old_child, new_child);