JavaScript/Removing Elements

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search
Previous: Changing Element Styles Index Next: Event Handlers

You can remove elements in Javascript with ease.

[edit] The correct way

//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