XML DOM removeAttributeNS() ວິທິງ

ການສະແດງຫຼືການນຳໃຊ້

removeAttributeNS() ວິທິງທີ່ຫຼຸດປະກອບຂໍ້ຈາກຊື່ນາມແລະຊື່ນາມຄົນສະນັກງານ:

ວິທິງ

elementNode.removeAttributeNS(ns,name)
ປະເພດ ການອະທິບາຍ
ns ສະຫຼຸບທີ່ຈຳເປັນ。ກໍານົດຊື່ນາມຂອງປະກອບຂໍ້:
name ສະຫຼຸບທີ່ຈຳເປັນ。ກໍານົດຊື່ຂອງປະກອບຂໍ້ທີ່ຈະຖອນ:

ຕົວຢ່າງ

ລະບັບດັ່ງລຸ່ມນີ້ຈະ "books_ns.xml" ນໍາໄປໃນ xmlDoc ແລະ ຖອນປະກອບຂໍ້ "lang" ຈາກ <title> ສະຖານທີ່ທໍາອິດ:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   }
};
xhttp.open("GET", "books_ns.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.getElementsByTagName("title")[0];
    var ns = \"https://www.codew3c.com/meishi/\";
    document.getElementById("demo").innerHTML =
    "ຄົ້ນພົບປະກອບຂໍ້: " + x.hasAttributeNS(ns, \"lang\");
    x.removeAttributeNS(ns, "lang");
    document.getElementById("demo").innerHTML +=
    "<br>Attribute Found: " + x.hasAttributeNS(ns, "lang");
}

亲自试一试