Element.removeAttribute()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

removeAttribute elimina un atributo del elemento especificado.

Sintaxis

js
element.removeAttribute(attrName);
  • attrName es una cadena que nombra el atributo a ser eliminado de element.

Ejemplo

js
// <div id="div1" align="left" width="200px">
document.getElementById("div1").removeAttribute("align");
// ahora: <div id="div1" width="200px">

Notas

Debe usarse preferiblemente removeAttribute en lugar de establecer el valor del atributo a null usando setAttribute.

Intentar eliminar un atributo que no existe en el elemento no disparará una excepción.

Especificaciones

Specification
DOM
# ref-for-dom-element-removeattribute①

Compatibilidad con navegadores

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
removeAttribute

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.