您的位置:58脚本 > XML DOM removeAttributeNode() 方法——Element 对象

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

2023-05-26 10:32 XMLDOM教程

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

XML DOM removeAttributeNode() 方法


Element 对象参考手册 Element 对象

定义和用法

removeAttributeNode() 方法删除指定的属性节点。

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

该函数返回要删除的属性节点。

语法

elementNode.removeAttributeNode(node)

参数 描述
node 必需。要删除的节点。


实例

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

实例

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

for(i=0;i<x.length;i++)
{
attnode=x.item(i).getAttributeNode("category");
old_att=x.item(i).removeAttributeNode(attnode);
document.write("Removed attribute: " + old_att.name + "
");
}

输出:

Removed attribute: category
Removed attribute: category
Removed attribute: category
Removed attribute: category


Element 对象参考手册 Element 对象
阅读全文
以上是58脚本为你收集整理的 XML DOM removeAttributeNode() 方法——Element 对象全部内容。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
相关文章
© 2024 58脚本 58jiaoben.com 版权所有 联系我们
桂ICP备12005667号-28 Powered by CMS