Element:getAttributeNodeNS() 方法

Element 实例的 getAttributeNodeNS() 方法返回元素的指定命名空间的 Attr 节点。

如果你需要限定命名空间的属性的实例属性,此方法会很有用。如果你只需要限定命名空间的属性的值,你可以改用 getAttributeNS() (en-US) 方法。

如果你需要 HTML 文档中的元素的 Attr 节点,并且属性没有限定命名空间,那么可以改用 getAttributeNode() 方法。

语法

js
getAttributeNodeNS(namespace, nodeName)

参数

  • namespace:指定属性的命名空间的字符串。
  • nodeName:指定属性名称的字符串。

返回值

指定属性的节点。

备注

getAttributeNodeNS 相比 getAttributeNode 更加具体,因为它允许你指定属于特定命名空间的属性。对应的 setter 方法是 setAttributeNodeNS

规范

Specification
DOM Standard
# dom-element-getattributenodens

浏览器兼容性

BCD tables only load in the browser

参见