天天看點

HTML DOM removeChild() 方法

HTML DOM removeChild() 方法

元素對象

從子節點清單中删除某個節點:

var list=document.getElementById("myList");

list.removeChild(list.childNodes[0]);

移除前:

Coffee

Tea

Milk

移除後:

removeChild() 方法可從子節點清單中删除某個節點。

如删除成功,此方法可傳回被删除的節點,如失敗,則傳回 NULL。

HTML DOM removeChild() 方法
HTML DOM removeChild() 方法
HTML DOM removeChild() 方法
HTML DOM removeChild() 方法
HTML DOM removeChild() 方法

所有主要浏覽器都支援 removeChild 方法

node.removeChild(node)

參數

類型

描述

node

節點對象

必須。 你要移除的節點對象。

移除的節點

DOM 版本

Core Level 1 Node Object

HTML DOM removeChild() 方法