JavaScript/Removing Elements

From Wikibooks, open books for an open world
< JavaScript
Jump to: navigation, search
Previous: Changing Element Styles Index Next: Event Handlers

You can remove elements from the document in JavaScript as follows.

//get the element node
element = document.getElementById("element");
 
//remove the element from the document
document.removeChild(element);

This would remove the element with id 'element'.

Previous: Changing Element Styles Index Next: Event Handlers