Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. Web API
  3. Element
  4. removeAttribute()

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

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 2015年7月.

ElementremoveAttribute() メソッドは、指定された名前の属性を要素から削除します。

構文

js
removeAttribute(attrName)

引数

attrName

文字列で、要素から削除する属性名を指定します。指定した属性が存在しなかった場合、removeAttribute() はエラーを発生させずに戻ります。

返値

なし (undefined)。

使用上のメモ

属性の値を直接、またはsetAttribute() を使用してnull に設定するのではなく、removeAttribute() を使用してください。多くの属性はnull に設定しても、期待通りの動作をしません。

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

仕様書

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

ブラウザーの互換性

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp