removeChild() method is used to delete a child node of the parent node.
Syntax:
parent.removeChild(thisNode)
Parameter description:
For example, delete id=" demo" node statement is:
var thisNode=document.getElementById("demo"); thisNode.parentNode.removeNode(thisNode);
For example, delete the node:
<div id="demo"> <div id="thisNode">点击删除我</div> </div> <script type="text/javascript"> document.getElementById("thisNode").onclick=function(){ this.parentNode.removeChild(this); } </script>
It can be seen that although Javascript only provides one method to delete nodes, it is enough.
Next Section