Element: getAttributeNodeNS() 方法

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

Element 介面的 getAttributeNodeNS() 方法返回元素的名稱空間 Attr 節點。

如果您需要獲取名稱空間屬性的 例項屬性,此方法將非常有用。如果您只需要名稱空間屬性的值,則可以使用 getAttributeNS() 方法代替。

如果您在 HTML 文件中需要元素的 Attr 節點,並且該屬性沒有名稱空間,請使用 getAttributeNode() 方法代替。

語法

js
getAttributeNodeNS(namespace, nodeName)

引數

namespace

一個指定屬性名稱空間的字串。

nodeName

指定屬性名稱的字串。

返回值

指定屬性的節點。

注意

getAttributeNodeNSgetAttributeNode 更具體,因為它允許您指定屬於特定名稱空間的屬性。對應的設定器方法是 setAttributeNodeNS

規範

規範
DOM
# dom-element-getattributenodens

瀏覽器相容性

另見