How to use DOM Element removeAttributeNS in JavaScript

In this article I am going to explain about DOM Element removeAttribute() method in JavaScript
  • 1840

JavaScript DOM Element removeAttributeNS() Method

JavaScript removeAttributeNS() method use for remove attribute with specified tag name from specified namespace.






    <script type="text/javascript">

        var http;

        if (window.XMLHttpRequest) { Xm = new XMLHttpRequest(); }

        else { Xm = new ActiveXObject("Microsoft.XMLHTTP"); }

 "GET", "myfile.xml", false);


        var xmlDoc = Xm.responseXML;

        var x = xmlDoc.getElementsByTagNameNS("", "name")[0];


        function check() {

            var y = x.hasAttributeNS("", "currency");

            document.getElementById("tst").innerHTML = y;



        function remove() {

            x.removeAttributeNS("", "currency");





    <button onclick="check()">

        click me</button>

    <button onclick="remove()">

        Remove attribute</button>

    <p id="tst" style="color: Blue">

        click button to check name element has currency attribute exist or not</p>






Before click




After click




You may also want to read these related articles: here
Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.