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.codew3c.com/children/";
document.write("Attribute ਮਿਲਿਆ: ");
document.write(x.hasAttributeNS(ns,"lang"));
x.removeAttributeNS(ns,"lang");
document.write("<br />Attribute ਮਿਲਿਆ: ");
document.write(x.hasAttributeNS(ns,"lang"));

ਆਉਟਪੁਟ:

Attribute ਮਿਲਿਆ: ਠੀਕ
Attribute ਮਿਲਿਆ: ਝੁੰਦਾ