This example describes the DOM node deletion function removechild () usage. Share to everyone for your reference. The specific analysis is as follows:
The DOM deletes a node and must be deleted at the height of the parent node, as follows:
Copy Code code as follows:
<script type= "Text/javascript" >
function T () {
Train of thought: 1. First find the node to delete; 2. Finds its parent node, deletes the child nodes at the parent node's point of view
var Nodeul = document.getelementsbytagname (' ul ') [0];//Find parent node
var Li_lan = nodeul.children[2];//Find the child node to delete
Nodeul.removechild (Li_lan);//use RemoveChild () function to delete
}
</script>
<body>
<div id= "Container" >
<ul>
<li> Spring </li>
<li> Summer </li>
<li> Blue Sky </li>
<li> Autumn </li>
<li> Winter </li>
</ul>
</div>
<div id= "Copyul" >
</div>
<button onclick= "t ()" value= "" > Delete a child node </button>
</body>
I hope this article will help you with your JavaScript programming.