Element: removeAttributeNode() method
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.
Thuộc tính removeAttributeNode() của giao diện Element removes the specified Attr node from the element.
If you don't need to inspect the attribute node before removing it, you can use the Element.removeAttribute() method instead.
Cú pháp
removeAttributeNode(attributeNode)
Tham số
attributeNode-
The attribute node to remove from the element.
Giá trị trả về
The attribute node that was removed.
Ngoại lệ
NotFoundErrorDOMException-
Thrown when the element's attribute list does not contain the attribute node.
Ví dụ
// Given: <div id="foo" lang="vi" />
const d = document.getElementById("foo");
const dLang = d.getAttributeNode("lang");
d.removeAttributeNode(dLang);
// lang is now removed: <div id="foo" />
Notes
If the removed attribute has a default value, it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.
There is no removeAttributeNodeNS method; the
removeAttributeNode method can remove both namespaced attributes and
non-namespaced attributes.
Đặc tả kỹ thuật
| Specification |
|---|
| DOM> # dom-element-removeattributenode> |