
定义和用法
hasChildNodes() 方法在当前元素节点拥有子节点时返回 TRUE,否则返回 FALSE。
语法
elementNode.hasChildNodes()
实例
下面的代码片段使用 loadXMLDoc() 把 "books.xml" 载入 xmlDoc 中,并检查第一个 <book> 元素是否拥有子节点:
实例
xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName("book")[0]; document.write(x.hasChildNodes());
输出:
true
