Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Element
  4. removeAttribute()

Element: removeAttribute() method

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.

TheElement methodremoveAttribute() removes the attribute with thespecified name from the element.

Syntax

js
removeAttribute(attrName)

Parameters

attrName

A string specifying the name of the attribute to remove from theelement. If the specified attribute does not exist,removeAttribute()returns without generating an error.

Return value

None (undefined).

Usage notes

You should useremoveAttribute() instead of setting the attribute value tonull either directly or usingsetAttribute().Many attributes will not behave as expected if you set them tonull.

Examples

js
// Given: <div disabled width="200px">document.getElementById("div1").removeAttribute("disabled");// Now: <div width="200px">

Specifications

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

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp