DOM
Element 实例的 getAttributeNodeNS() 方法返回元素的指定命名空间的 Attr 节点。
如果你需要限定命名空间的属性的实例属性,此方法会很有用。如果你只需要限定命名空间的属性的值,你可以改用 Element.getAttributeNS() 方法。
如果你需要 HTML 文档中的元素的 Attr 节点,并且属性没有限定命名空间,那么可以改用 Element.getAttributeNode() 方法。
语法
getAttributeNodeNS(namespace, nodeName)
参数
namespace:指定属性的命名空间的字符串。nodeName:指定属性名称的字符串。
返回值
指定属性的节点。
备注
getAttributeNodeNS 相比 getAttributeNode 更加具体,因为它允许你指定属于特定命名空间的属性。对应的 setter 方法是 setAttributeNodeNS。
规范
浏览器兼容性
参见
- Document.createAttribute()
- Document.createAttributeNS()
- Element.setAttributeNodeNS()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
