روش removeAttribute() DOM XML
تعریف و استفاده
removeAttribute()
روش
اگر مقدار پیشفرض ویژگی در DTD تعریف شده باشد، یک ویژگی جدید با مقدار پیشفرض فوراً ظاهر میشود.
گرامر
elementNode.removeAttribute(name)
پارامتر | توضیح |
---|---|
name | ضروری. تعیین ویژگیای که باید حذف شود. |
مثال
در اینجا کد به "books.xml" بارگذاری میشود و از تمام عناصر <book> ویژگی "category" حذف میشود:
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'); }