现在位置: 首页 > XML DOM 教程 > 正文

XML DOM removeAttributeNS() 方法


Element 对象参考手册 Element 对象

定义和用法

removeAttributeNS() 方法删除通过命名空间和名称指定的属性。

语法

elementNode.removeAttributeNS(ns,name)

参数 描述
ns 必需。规定要删除的属性的命名空间。
name 必需。规定要删除的属性的名称。


实例

下面的代码片段使用 loadXMLDoc() 把 "books_ns.xml" 载入 xmlDoc 中,并删除第一个 <title> 元素的 "lang" 属性:

实例

xmlDoc=loadXMLDoc("books_ns.xml"); x=xmlDoc.getElementsByTagName("title")[0]; ns="http://www.runoob.com/w3cnote/"; document.write("Attribute Found: "); document.write(x.hasAttributeNS(ns,"lang")); x.removeAttributeNS(ns,"lang"); document.write("<br>Attribute Found: "); document.write(x.hasAttributeNS(ns,"lang"));

输出:

Attribute Found: true
Attribute Found: false

尝试一下 »

Element 对象参考手册 Element 对象