Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM removeChild() Method

XML DOM removeChild() Method


Element Object Reference Element Object


Definition and Usage

The removeChild() method deletes a child node.

This function returns the removed node if successful, or NULL if it fails.

Syntax

elementNode.removeChild(node)

Parameters Description
node Required. Specifies the child node to delete.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" load into xmlDoc, and delete the first the child nodes of an element:

Example

xmlDoc=loadXMLDoc("books.xml");

y=xmlDoc.getElementsByTagName("book")[0];

x=xmlDoc.documentElement.removeChild(y);

document.write("Removed node: " + x.nodeName);

Output:

Node removed: book

Try it »


Try it Demos

removeChild() - Remove the last child node from a node list


Element Object Reference Element Object