Deleting objects
Again, the removal of a node is a method that is applied to its parent node.
Name | Meaning |
---|---|
.removeChild(oldChild) |
removes the child oldChild of parent |
In certain circumstances, one might wish to use the method removeChild(oldChild)
in conjunction with the parentNode
method, as in element.parentNode.removeChild(element)
. This can lead to unexpected behaviour due to the DOM refreshing and changing. It is safer to instead use the following sequence of steps:
var parent = element.parentNode;
parent.removeChild(element);
Note:
Hints:
- undefined
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX