DOM:element.hasChildNodes
From MDC
Contents |
[edit] Summary
hasChildNodes returns a Boolean value indicating whether the current element has child nodes or not.
[edit] Syntax
result = element.hasChildNodes()
[edit] Example
remove the first child node inside the element with the id "foo" if foo has child nodes
var foo = document.getElementById("foo")
if (foo.hasChildNodes()) {
foo.removeChild(foo.childNodes[0]);
}
Note that element.hasChildNodes, without the parenthesises, will return the hasChildNodes Function, and not a Boolean.