Replacing or Removing nodes

Let's remove or replace elements from the page via JavaScript.

We'll cover the following

Replacing a node

A DOM element can be replaced with the replaceChild() method. This replaces a child node of the current element with another node. The new node and existing node replaced are passed as parameters (in that order). The example shows replacing the Perl language with Lisp.

Get hands-on with 1200+ tech skills courses.