语法
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 |
浏览器兼容性
加载中…