removechild 从父节点上删除某个子节点
<div id="app">
<p>one</p>
<p id="two">two</p>
<button id="btn">点击消失</button>
</div>
<!-- removeChild 从父节点上删除某个子节点
parentElment.removeChlid(childElement)
remove();
-->
<script>
var app=document.getElementById("app");
var two=document.getElementById("two");
var btn=document.getElementById("btn");
btn.onclick=function(){
app.removeChild(two);
}
remove() 方法
<div id="app">
<p>one</p>
<p id="two">two</p>
<button id="btn">点击消失</button>
</div>
<script>
var app=document.getElementById("app");
var two=document.getElementById("two");
var btn=document.getElementById("btn");
btn.onclick=function(){
two.remove();
}