This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Gets a value that indicates whether the Node has any direct Node descendant of any type.

Method of dom/Nodedom/Node


var hasChildNodes = element.hasChildNodes();

Return Value

Returns an object of type BooleanBoolean

Whether or not the Node contains any direct Node descendant of any type


The following example removes the first child node inside the element with the id “foo” if foo has child nodes.

var foo = document.getElementById("foo");

if (foo.hasChildNodes()) {

{{Notes_Section |Notes=If the Node contains any [[dom/Element|Element], [dom/Text|Text] or other type of nodes, they can be accessed from the childNodes collection. }}

Related specifications

Document Object Model (DOM) Level 3 Core
W3C Recommendation