NamedNodeMap: phương thức removeNamedItemNS()
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.
Phương thức removeNamedItemNS() của giao diện NamedNodeMap xóa Attr tương ứng với không gian tên và tên cục bộ đã cho khỏi map.
Cú pháp
js
removeNamedItemNS(namespace, localName)
Tham số
Giá trị trả về
Attr đã bị xóa.
Ngoại lệ
NotFoundErrorDOMException-
Được ném nếu không có thuộc tính nào với không gian tên và tên cục bộ đã cho.
Ví dụ
js
const parser = new DOMParser();
const xmlString =
'<warning ob:one="test" xmlns:ob="http://www.example.com/ob">Beware!</warning>';
const doc = parser.parseFromString(xmlString, "application/xml");
const pre = document.querySelector("pre");
const warning = doc.querySelector("warning");
const attrMap = warning.attributes;
let result = `The 'ob:one' attribute initially contains '${attrMap["ob:one"].value}'.\n`;
result += "We remove it.\n\n";
attrMap.removeNamedItemNS("http://www.example.com/ob", "one");
result += attrMap["ob:one"]
? "And 'ob:one' still exists."
: "And 'ob:one' is no more to be found.";
pre.textContent = result;
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| DOM> # dom-namednodemap-removenameditemns> |