DOM Node hasChildNodes() method
Example
View all child nodes of an element:
document.getElementById("myList").hasChildNodes()
Output result:
true
Try it »
Definition and Usage
The hasChildNodes() method returns true if a node has any child nodes, otherwise it returns false.
Browser support





All major browsers support the hasChildNodes() method
Syntax
node
.hasChildNodes()
Parameters
None
Return Value
| Type | Description |
|---|---|
| Boolean | Returns true if the node has child nodes, otherwise returns false. |
Technical Details
| DOM version | Core Level 1 Node Object |
|---|
Element object