How to use DOM Element RemoveAttribute in JavaScript

In this article I am going to explain about DOM element removeAttribute() method in JavaScript.
  • 1634

JavaScript DOM Element removeAttribute() Method

JavaScript removeAttribute() method use for remove the specified attribute.

Syntax

element.removeAttribute(attribute name)

Example

<html>

<head>

    <h2 style="color: blue;">

        Hello India</h2>

    <script type="text/javascript">

 

        function myfun() {

            document.getElementsByTagName("H2")[0].removeAttribute("style");

        };

 

    </script>

</head>

<body>

    <p>

        click button for remove style attribute</p>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

Before click

 

 remove1.gif

 

After click

 

 remove2.gif

 

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
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.