XML DOM hasAttributes() 方法

定义和用法

如果当前元素节点拥有任何属性,则 hasAttributes() 返回 true,否则返回 false。

语法:

hasAttributes()

实例

在所有的例子中,我们将使用 XML 文件 books.xml,以及 JavaScript 函数 loadXMLDoc()

下面的代码片段检查 "books.xml" 中的第一个 <book> 元素是否拥有属性:

xxmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book')[0];

document.write(x.hasAttributes());

以上代码的输出:

true
系统帮助 | 给我留言 | 收藏本站
Copyright © 2005-2008 www.cnn84.com All Rights Reserved Ver:2.0
CNN84网是公益性便民网站,是为了给大家的日常生活查询及提供最快捷的出行指南