This translation is incomplete. Please help translate this article from English


通过命名空间 URI 和名称来获取属性节点。


attributeNode = element.getAttributeNodeNS(namespace,nodeName) 
  • attributeNode 获取的属性节点.
  • namespace 命名空间字符串
  • nodeName 属性节点的名称.

== Example == TBD The example needs to be fixed pre> // html: <div id="top" /> t = document.getElementById("top"); specialNode = t.getAttributeNodeNS( "http://www.mozilla.org/ns/specialspace", "id"); // iNode.value = "full-top" </pre


getAttributeNodeNS 相比 getAttributeNode 更加具体,允许你在特定的命名空间里获取属性. 对应的 setter 方法是 setAttributeNodeNS.

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 getAttributeNode getAttributeNodeNS
hasAttribute (DOM 2) hasAttributeNS - -
removeAttribute (DOM 1) removeAttributeNS removeAttributeNode -


DOM Level 2 Core: getAttributeNodeNS