asp.net.ph

Skip Navigation Links

removeChild Method

DHTML Methods


DOM Level 1 Specification.

Removes a child node from an element.

Syntax

object.removeChild ( oNode ) 
Parameters

oNode Required. The element to be removed from the document.

Return Value

Returns the node removed.

Remarks

The node to be removed must be an immediate child of the parent object. An exception occurs when oNode is not a child of this node, or when the specified oNode is read-only and cannot be removed.

Example

This sample demonstrates removing a bold element from a div using the removeChild method.

Click anywhere in this sentence to remove this Bold word.
<div id=Div1 onclick="removeElement ( )">
  Click anywhere in this sentence to remove this 
    <b>Bold</b> word.</div>
<script language="JavaScript">
function removeElement ( ) {
try {
var oChild=Div1.children ( 0 );
Div1.removeChild ( oChild );
}
catch ( x ) {
alert ( "You have already removed the bold element. 
  Page will be refreshed when you click OK." )
document.location.reload ( );}
}
</script>
See Also

appendChild, replaceChild



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note