removeAttribute method
The removeAttribute method removes
the given attribute from some tag.
Syntax
element.removeAttribute(attribute name);
Example
Let's remove the
value
attribute from an element:
<input id="elem" value="abcde">
let elem = document.querySelector('#elem');
elem.removeAttribute('value');
The HTML code will look like this (the value attribute will disappear):
<input id="elem">
See also
-
the
getAttributemethod
that gets attributes -
the
setAttributemethod
that sets attributes -
the
hasAttributemethod
that checks attributes