طريقة removeAttribute() من XML DOM

التعريف والاستخدام

removeAttribute() الطريقة

إذا تم تعريف قيمة افتراضية للخاصية في DTD، فإن الخاصية الجديدة التي تحتوي على القيمة الافتراضية ستظهر على الفور.

الجملة

elementNode.removeAttribute(name)
المتغيرات وصف
name مطلوب. يحدد الخاصية التي سيتم إزالتها.

مثال

الشيفرة التالية ستقوم بتحميل "books.xml" إلى xmlDoc وإزالة خصائص "category" من جميع عناصر <book>:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   }
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.getElementsByTagName("book");
    document.getElementById("demo").innerHTML =
    x[0].getAttribute('category') + "<br>";
    x[0].removeAttribute('category');
    document.getElementById("demo").innerHTML +=;
    x[0].getAttribute('category');
}

جرب بنفسك