February 2006
Intermediate to advanced
826 pages
63h 42m
English
Because we’re on the topic of node manipulation, we should take a look at the removeChild( ) method as well.
Using removeChild( ), we can remove a single node or an entire node tree from the document. This method takes a single argument: the node you want to remove. Suppose we wanted to remove the text node from our div. We could accomplish that easily using removeChild( ):
div.removeChild( div.firstChild );
We could even use removeChild( ) to delete the entire body from the page, which would not be a good thing, but demonstrates its power:
body.parentNode.removeChild( body );
Read now
Unlock full access