NamedNodeMap.removeNamedItem()

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.

removeNamedItem()NamedNodeMap インターフェイスのメソッドで、指定された名前に対応する Attr をマップから取り除きます。

構文

js
removeNamedItem(attrName);

引数

attrName

マップから取り除く属性の名前。

返値

取り除かれた Attr

例外

NotFoundError DOMException

指定された名前の属性がなかった場合に発生します。

html
<pre test="testValue"></pre>
js
const pre = document.getElementsByTagName("pre")[0];
const attrMap = pre.attributes;

let result = `The 'test' attribute initially contains '${attrMap["test"].value}'.\n`;

result += "We remove it.\n\n";
attrMap.removeNamedItem("test");

if (attrMap.getNamedItem("test")) {
  result += "And 'test' still exists.";
} else {
  result += "And 'test' is no more to be found.";
}

pre.textContent = result;

仕様書

Specification
DOM
# dom-namednodemap-removenameditem

ブラウザーの互換性

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
removeNamedItem

Legend

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

Full support
Full support