/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: hasChildNodes()

[this page | pdf | back links]

The hasChildNodes() method (when applied to HTML elements in the JavaScript DOM) returns true if the element has any child nodes, otherwise it returns false. Note: whitespace inside a node is deemed to form a (child) text node, and so will result in a true value being returned by this method.

 

It has the following syntax with no parameters. It returns a Boolean as above. It can be applied to any node, but if the node is not an element then it will always return false.

 

element.hasChildNodes()

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile