THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

XML DOM removeAttributeNS() Method


Element Object Reference Element Object

Example

The following code fragment loads "books_ns.xml" into xmlDoc and removes the "lang" attribute from the first <title> element:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
��� if (xhttp.readyState == 4 && xhttp.status == 200) {
������� myFunction(xhttp);
��� }
};
xhttp.open("GET", "books_ns.xml", true);
xhttp.send();

function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.getElementsByTagName("title")[0];
    var ns = "http://www.w3schools.com/children/";
    document.getElementById("demo").innerHTML =
    "Attribute Found: " + x.hasAttributeNS(ns, "lang");

    x.removeAttributeNS(ns, "lang");
    document.getElementById("demo").innerHTML +=
    "<br>Attribute Found: " + x.hasAttributeNS(ns, "lang");
}

Output:

Attribute Found: true
Attribute Found: false
Try it yourself »

Definition and Usage

The removeAttributeNS() method removes an attribute specified by namespace and name.

Syntax

elementNode.removeAttributeNS(ns,name)

Parameter Description
ns Required. Specifies the namespace of the attribute to remove
name Required. Specifies the name attribute to remove

Element Object Reference Element Object