Element: removeAttributeNode() メソッド
removeAttributeNode()
は Element
インターフェイスのメソッドで、この要素から指定された属性を除去します。
構文
js
removeAttributeNode(attributeNode)
引数
attributeNode
-
この要素から除去する属性ノードです。
返値
除去された属性ノードです。
例外
NotFoundError
DOMException
-
要素の属性リストに属性ノードが含まれていない場合に発生します。
例
js
// Given: <div id="top" align="center" />
const d = document.getElementById("top");
const d_align = d.getAttributeNode("align");
d.removeAttributeNode(d_align);
// align is now removed: <div id="top" />
メモ
削除された属性に既定値がある場合、それは直ちに置き換えられます。置換される属性は、同じ名前空間 URI とローカル名、そして必要に応じて元の接頭辞を持ちます。
removeAttributeNodeNS
メソッドはありません。removeAttributeNode
メソッドは、名前空間付き属性と名前空間付きでない属性の両方を削除することができます。
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 |
- |
仕様書
Specification |
---|
DOM Standard # dom-element-removeattributenode |
ブラウザーの互換性
BCD tables only load in the browser