JavaScript element.removeAttribute() Method

You are Here:

JavaScript element.removeAttribute() Method

The element.removeAttribute() method removes the attribute with the specified name from the specified element.

Tips: To set the current value of an attribute, use element.setAttribute().

Tips: To get the current value of an attribute, use element.getAttribute().

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <p style="color:blue;">Click on the button to remove 'style' attribute of this paragraph.</p> <button onclick="myFunction()">Click Me</button> <script> var elem = document.getElementsByTagName("p")[0]; function myFunction(){ elem.removeAttribute("style"); } </script> </body> </html>

Syntax

element.removeAttribute(attrName)

Parameter Values

ValueTypeExplanation
attrNameRequiredA DOMString specifying the name of the attribute to remove from the element.

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author