February 2006
Intermediate to advanced
826 pages
63h 42m
English
Let’s suppose that instead of inserting our new div before the firstChild of the body element, we wanted it to replace the firstChild.
To do so, we could use the replaceChild( ) method:
body.replaceChild( new_div, body.firstChild );
Like insertBefore( ), replaceChild( ) takes two arguments: The first argument is the node you want inserted in the place of the node that is the second argument.
Read now
Unlock full access