XML DOM hasAttributes() 方法
定義和用法
hasAttributes() 方法會(huì)在某節(jié)點(diǎn)用于任何屬性時(shí)返回 true,否則返回 false。
語(yǔ)法:
nodeObject.hasAttributes()
實(shí)例
在所有的例子中,我們將使用 XML 文件 books.xml,以及 JavaScript 函數(shù) loadXMLDoc()。
下面的代碼片段可返回是否首個(gè) <book> 元素用于任何的屬性:
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes()
);
輸出:
true