Element: removeAttributeNode() メソッド

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.

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 メソッドは、名前空間付き属性と名前空間付きでない属性の両方を削除することができます。

仕様書

Specification
DOM
# dom-element-removeattributenode

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
removeAttributeNode

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support