中国最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2

xmldom教程

XML DOM removeAttribute() 方法——Element 对象

阅读 (1727)

XML DOM removeAttribute() 方法


Element 对象参考手册 Element 对象

定义和用法

removeAttribute() 方法删除指定的属性。

如果属性的默认值是在 DTD 中定义,那么新属性出现时会带有该默认值。

语法

elementNode.removeAttribute(name)

参数 描述
name 必需。规定要删除的属性。


实例

下面的代码片段使用 loadXMLDoc() 把 "books.xml" 载入 xmlDoc 中,并删除所有 <book> 元素的 "category" 属性:

实例

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

document.write(x[0].getAttribute('category'));
document.write("
");

x[0].removeAttribute('category');

document.write(x[0].getAttribute('category'));

尝试一下 »

Element 对象参考手册 Element 对象
关闭
程序员人生