XML DOM removeAttributeNS() ·½·¨

¶¨ÒåºÍÓ÷¨

removeAttributeNS() ·½·¨É¾³ýÓÉÃüÃû¿Õ¼äºÍÃû³ÆÖ¸¶¨µÄÊôÐÔ¡£

Óï·¨£º

elementNode.removeAttributeNS(ns,name)
²ÎÊý ÃèÊö
ns ±ØÐè¡£¹æ¶¨ÒªÉ¾³ýµÄÊôÐÔµÄÃû×ֿռ䡣
name ±ØÐè¡£¹æ¶¨ÒªÉ¾³ýµÄÊôÐÔµÄÃû³Æ¡£

ʵÀý

ÔÚËùÓеÄÀý×ÓÖУ¬ÎÒÃǽ«Ê¹Óà XML Îļþ books_ns.xml£¬ÒÔ¼° JavaScript º¯Êý loadXMLDoc()¡£

ÏÂÃæµÄ´úÂëÆ¬¶Î´Ó "books_ns.xml" ÖеĵÚÒ»¸ö <title> ÔªËØÉ¾³ý "lang" ÊôÐÔ£º

xmlDoc=loadXMLDoc("books_ns.xml");

x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.w3school.com.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
VUE