XML DOM removeAttributeNS() 方法
Element 對(duì)象
定義和用法
removeAttributeNS() 方法刪除通過(guò)命名空間和名稱(chēng)指定的屬性。
語(yǔ)法
elementNode.removeAttributeNS(ns,name)
參數(shù) | 描述 |
ns | 必需。規(guī)定要?jiǎng)h除的屬性的命名空間。 |
name | 必需。規(guī)定要?jiǎng)h除的屬性的名稱(chēng)。 |
實(shí)例
下面的代碼片段使用 loadXMLDoc() 把 "books_ns.xml" 載入 xmlDoc 中,并刪除第一個(gè) <title> 元素的 "lang" 屬性:
實(shí)例
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.vxbq.cn/s/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 對(duì)象