Javascript examples for DOM:Element removeChild
The removeChild() method removes a child node from an element.
It returns the removed node as a Node object, or null if the node does not exist.
Parameter | Type | Description |
---|---|---|
node | Node object | Required. The node object you want to remove |
A Node object, representing the removed node, or null if the node does not exist
The following code shows how to Remove the <span> element.
<!DOCTYPE html> <html> <body> <div id="myDIV"> <span id="mySpan" style="font-size:35px;">A Span element</span> </div>/*from w w w .jav a 2 s . c o m*/ <button onclick="removeSpan()">Remove span</button> <script> var child = document.getElementById("mySpan"); function removeSpan() { child.parentNode.removeChild(child); } </script> </body> </html>