Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

element.removeAttribute

 

このページは翻訳中です。
翻訳作業に参加する場合は、履歴にある翻訳者と連絡·調整してください。


概要

removeAttribute は指定の要素から属性を取り除きます。

構文

element.removeAttribute(attrName) 
  • attrName element から取り除く属性の名前を表す文字列です。

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

注記

setAttribute を使って属性の値に null をセットする代わりに removeAttribute を使用すべきです。

要素にない属性を取り除こうと試みても例外は発生しません。

DOM メソッドは要素の属性を取り扱います。

名前空間に無関係、
最も一般的に使用されるメソッド
名前空間に限定される変数
(DOM Level 2)
Attr ノードを直接扱う DOM レベル 1 のメソッド
(ほとんど使用されない)
Attr ノードを直接扱う DOM レベル 2 名前空間に限定されるメソッド
(ほとんど使用されない)
setAttribute (DOM 1) setAttributeNS setAttributeNode setAttributeNodeNS
getAttribute (DOM 1) getAttributeNS getAttributeNode getAttributeNodeNS
hasAttribute (DOM 2) hasAttributeNS - -
removeAttribute (DOM 1) removeAttributeNS removeAttributeNode -

仕様

DOM Level 2 Core: removeAttribute (introduced in DOM Level 1 Core)

 

 

 

ドキュメントのタグと貢献者

タグ: 
 このページの貢献者: fscholz, khalid32, Mgjbot, Ryotakano
 最終更新者: khalid32,