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

2018-08-05 19:13 更新

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="//www.w3cschool.cn/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 对象
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号