Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM hasChildNodes method

DOM Node hasChildNodes() method

Element Object Reference Element object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Element object