Element.removeAttributeNS()
removeAttributeNS
移除元素的指定属性
在 Firefox 3 及更高版本中,此方法会将 DOM 值重置为其默认值。
用法
element.removeAttributeNS(namespace,attrName);
namespace
包含当前属性的 namespace 字符串attrName
当前移除的属性名字符串
例子
// <div id="div1" xmlns:special="http://www.mozilla.org/ns/specialspace" // special:specialAlign="utterleft" width="200px" /> d = document.getElementById("div1"); d.removeAttributeNS("http://www.mozilla.org/ns/specialspace", "specialAlign"); // now: <div id="div1" width="200px" />
Notes
DOM methods dealing with element's attributes:
Not namespace-aware, most commonly used methods | Namespace-aware variants (DOM Level 2) | DOM Level 1 methods for dealing with Attr nodes directly (seldom used) |
DOM Level 2 namespace-aware methods for dealing with Attr nodes directly (seldom used) |
---|---|---|---|
setAttribute (DOM 1) |
setAttributeNS |
setAttributeNode |
setAttributeNodeNS |
getAttribute (DOM 1) |
getAttributeNS (en-US) |
getAttributeNode |
getAttributeNodeNS |
hasAttribute (DOM 2) |
hasAttributeNS |
- | - |
removeAttribute (DOM 1) |
removeAttributeNS |
removeAttributeNode |
- |