removeAttributeNS() 方法刪除由命名空間和名稱指定的屬性。
elementNode.removeAttributeNS(ns,name)
參數(shù) | 描述 |
---|---|
ns | 必需。規(guī)定要刪除的屬性的名字空間。 |
name | 必需。規(guī)定要刪除的屬性的名稱。 |
在所有的例子中,我們將使用 XML 文件 books_ns.xml,以及 JavaScript 函數(shù) loadXMLDoc()。
下面的代碼片段從 "books_ns.xml" 中的第一個(gè) <title> 元素刪除 "lang" 屬性:
xmlDoc=loadXMLDoc("books_ns.xml"); x=xmlDoc.getElementsByTagName("title")[0]; ns="http://theartemis.cn/children/"; 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
如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答!! 點(diǎn)擊進(jìn)入論壇