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 GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
removeAttribute |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.