DOM Node hasChildNodes()Method
Examples
View all child nodes of an element:
document.getElementById("myList").hasChildNodes()
Output result:
true
Try it yourself »
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 |
|---|
Other Extensions
Element Object