Remocechild (): The method removes a child node from a given element:
Reference = element.removechild (node);
The return value of this method is a reference pointer to a child node that has been deleted.
When a node is deleted by the RemoveChild () method, all child nodes contained by the node are deleted at the same time.
In the following example, the id attribute value is content and the element containing this id attribute value is an element of fineprint, and we will use the RemoveChild () method to delete the FinePrint element from the content element:
var container = document.getElementById ("content"); var message = document.getElementById ("FinePrint"); contianer.removechild (message);
If you want to delete a node, but do not know which one the parent node is in, the ParentNode property can be used:
var message = document.getElementById ("FinePrint"); var container = message.parentnode;container.removechild (message);
If you want to move a node from one part of the document to another, you do not have to use the RemoveChild () method, and the AppendChild () and InsertBefore () methods automatically remove the node before inserting it into the new position.
Delete node (removechild ())