語法
js
removeNamedItem(attrName)
引數
attrName-
要從對映中移除的屬性的名稱。
返回值
被移除的 Attr。
異常
NotFoundErrorDOMException-
如果不存在具有給定名稱的屬性,則會丟擲此異常。
示例
html
<pre test="testValue"></pre>
js
const pre = document.querySelector("pre");
const attrMap = pre.attributes;
let result = `The 'test' attribute initially contains '${attrMap["test"].value}'.\n`;
result += "We remove it.\n\n";
attrMap.removeNamedItem("test");
result += attrMap.getNamedItem("test")
? "And 'test' still exists."
: "And 'test' is no more to be found.";
pre.textContent = result;
規範
| 規範 |
|---|
| DOM # dom-namednodemap-removenameditem |
瀏覽器相容性
載入中…