Element

Element.prototype.removeAttribute

Removes the attribute with the specified name from the element

Syntax

JavaScript
element.removeAttribute(name)

Parameters

ParameterTypeDescription
namestringThe name of the attribute to remove

Return Value

undefined

Examples

Basic Usage
const input = document.querySelector('input')!
input.removeAttribute('disabled')
Practical Example
function clearAriaAttributes(el: HTMLElement) {
  const attrs = el.getAttributeNames().filter(a => a.startsWith('aria-'))
  attrs.forEach(a => el.removeAttribute(a))
}
Advanced Usage
const el = document.querySelector('[data-temp]')!
el.removeAttribute('data-temp')
console.log(el.hasAttribute('data-temp')) // false

Understanding Element.prototype.removeAttribute

The Element.prototype.removeAttribute method in JavaScript removes the attribute with the specified name from the element. It belongs to the Element object and is one of the most widely used methods for working with element values in modern JavaScript and TypeScript applications.

The method signature is element.removeAttribute(name). It accepts 1 parameter: name. When called, it returns undefined. Understanding when and how to use removeAttribute() helps you write more expressive, readable code.

Common use cases for Element.prototype.removeAttribute include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like dom-setattribute, dom-getattribute, dom-hasattribute, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Element.prototype.removeAttribute is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Element Methods

Other methods in the Element object

Related Tools

More Element Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.