Element: removeAttributeNS() 方法

Baseline 已廣泛支援

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

Element 介面的 removeAttributeNS() 方法會移除元素上指定名稱空間中指定的屬性。

如果您正在處理 HTML,並且不需要將請求的屬性指定為特定名稱空間的一部分,請改用 removeAttribute() 方法。

語法

js
removeAttributeNS(namespace, attrName)

引數

namespace

包含屬性名稱空間的字串。

attrName

要從當前節點移除的屬性的名稱字串。

返回值

無(undefined)。

示例

js
// Given:
//   <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" />

規範

規範
DOM
# ref-for-dom-element-removeattributens①

瀏覽器相容性

另見