JavaScript: removeAttribute

The removeAttribute() method removes a named attribute from an HTML element.

What you will learn

Minimal example

<button id="save" disabled>Save</button>
const button = document.querySelector('#save');
if (button) button.removeAttribute('disabled');

The button is no longer disabled because the disabled attribute has been removed. Calling the method for an attribute that is not present does nothing.

Syntax

element.removeAttribute('attribute-name');

Pass the attribute name as a string, such as class, id, title, or aria-label. For classes, classList.remove() is often clearer when you want to remove only one class while keeping others.

Common mistakes