XML DOM removeAttribute() ਮੇਥਡ

ਵਿਆਖਿਆ ਅਤੇ ਵਰਤੋਂ

removeAttribute() ਮੇਥਡ ਵਿਸ਼ੇਸ਼ ਵਿਸ਼ੇਸ਼ਤਾ ਹਟਾ ਦਿੰਦਾ ਹੈ。

DTD ਵਿੱਚ ਵਿਸ਼ੇਸ਼ਤਾ ਦੀ ਮੂਲਤਬੀ ਮੁੱਲ ਨਾਲ ਨਵੀਂ ਵਿਸ਼ੇਸ਼ਤਾ ਦੇ ਸਾਥ ਸ਼ੁਰੂ ਹੁੰਦੀ ਹੈ。

ਗਰਿੱਖ

elementNode.removeAttribute(name)
ਪੈਰਾਮੀਟਰ ਵਰਣਨ
name ਲਾਜ਼ਮੀ। ਹਟਾਉਣੀ ਵਿਸ਼ੇਸ਼ਤਾ ਦੀ ਨਿਰਦੇਸ਼ਣ ਦਿੰਦਾ ਹੈ。

ਉਦਾਹਰਣ

ਹੇਠਲਾ ਕੋਡ "books.xml" ਨੂੰ xmlDoc ਵਿੱਚ ਲੋਡ ਕਰਦਾ ਹੈ, ਅਤੇ ਸਾਰੇ <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');
}

خود جربا جائیے