代码示例:(标识:jsck_node_removechild_4)
<!DOCTYPE html>
<html>
<body>

<h1>Element 对象</h1>

<h2>removeChild() 方法</h2>

<p>单击按钮从 ul 元素中删除和插入 li 元素:</p>
<button onclick="removeLi()">删除</button>
<button onclick="appendLi()">插入</button>

<ul id="myList">
  <li id="myLI">Coffee</li>
</ul>

<script>
const element = document.getElementById("myLI");

function removeLi() {
  element.parentNode.removeChild(element);
}
function appendLi() {
  const list = document.getElementById("myList");
  list.appendChild(element);
}
</script>

</body>
</html>
运行结果: