DOM Node hasChildNodes()Method

元素对象参考手册Element Object

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

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

Other Extensions