Node: phương thức removeChild()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Phương thức removeChild() của giao diện Node xóa một nút con khỏi nút hiện tại.
Cú pháp
js
removeChild(child)
Tham số
child-
Nút con cần xóa.
Giá trị trả về
Nút đã bị xóa.
Ngoại lệ
NotFoundErrorDOMException-
Được ném ra nếu
childkhông phải là nút con của nút hiện tại.
Ví dụ
js
const node = document.getElementById("box");
while (node.firstChild) {
node.removeChild(node.firstChild);
}