代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="father">
<h1>标题</h1>
<p id="p1">p1</p>
<p class="p2">p2</p>
</div>
<script>
//删除节点
//删除节点步骤:先获取父节点,再通过父节点删除自己
var h1 = document.getElementsByTagName("h1");
var p1 = document.getElementById("p1");
var p2 = document.getElementsByClassName("p2")
var father = document.getElementById("father");
father.removeChild(p1);
//获取父节点
// var temp = p2.parentElement;
//temp.removeChild("p2")
//删除是一个动态的过程
// father.removeChild(father.children[0]);
// father.removeChild(father.children[1]);
// father.removeChild(father.children[2]);
//删除多个节点的时候,children是在时刻变化的
</script>
</body>
</html>