removeAttribute method

The removeAttribute method removes the given attribute from some tag.

Syntax

javascriptelement.removeAttribute(attribute name);

Example

Let's remove the value attribute from an element:

html<input id="elem" value="abcde">
javascriptlet elem = document.querySelector('#elem');
elem.removeAttribute('value');

The HTML code will look like this (the value attribute will disappear):

html<input id="elem">

See also