X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

DOM Node hasChildNodes() Method

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


Element Object Reference Element Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook