Search w3schools.com:

SHARE THIS PAGE

DOM Node hasChildNodes() Method

Node Object Reference Node Object

Example

See if an element has any childNodes:

document.getElementById("myList").hasChildNodes()

The result will be:

true

Try it yourself »

Definition and Usage

The hasChildNodes() method returns true if the specified node has any childNodes, otherwise false.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The hasChildNodes() method is supported in all major browsers.


Syntax

node.hasChildNodes()

Parameters

None

Return Value

Type Description
Boolean true if the node has childnodes, otherwise false

Technical Details

DOM Version Core Level 1


Node Object Reference Node Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]