自强学堂
自强学堂:学习、分享、让你更强!
XML DOM 参考手册HTMLCSSJAVASCRIPTJQUERYSQLPHPBOOTSTRAPANGULARXML
 

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.ziqiangxuetang.com/children/";

document.write("Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));

x.removeAttributeNS(ns,"lang");

document.write("
Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));

输出:

Attribute Found: true
Attribute Found: false

尝试一下 »

Element 对象参考手册 Element 对象