DOM Element.removeAttribute() Method
The removeAttribute() method removes an attribute from an element.
Description
The removeAttribute() method removes the named attribute. Nothing happens if the attribute isn't there. It's the right way to turn off boolean attributes such as disabled and hidden.
Removing an attribute and setting it to an empty string aren't the same: for boolean attributes, an empty value still counts as present, so disabled="" keeps the element disabled. Some attributes fall back to a default when removed, such as type on an input becoming "text".
For ARIA states, removing the attribute and setting it to "false" can mean different things; for example, removing aria-expanded says the control isn't expandable at all. Check what each attribute's absence means before choosing.
Syntax
element.removeAttribute(name)Parameters
- nameThe name of the attribute to remove.
Return Value
None (undefined).
Example
Browser Support
The following information will show you the current browser support for the Element.removeAttribute() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





