aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/element/removeattributenode/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/element/removeattributenode/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/element/removeattributenode/index.html')
-rw-r--r--files/zh-cn/web/api/element/removeattributenode/index.html40
1 files changed, 40 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/element/removeattributenode/index.html b/files/zh-cn/web/api/element/removeattributenode/index.html
new file mode 100644
index 0000000000..aa4f31a331
--- /dev/null
+++ b/files/zh-cn/web/api/element/removeattributenode/index.html
@@ -0,0 +1,40 @@
+---
+title: Element.removeAttributeNode()
+slug: Web/API/Element/removeAttributeNode
+translation_of: Web/API/Element/removeAttributeNode
+---
+<p>{{ APIRef("DOM") }}</p>
+
+<p><code>removeAttributeNode</code> 从当前的 element(元素节点) 删除指定的属性</p>
+
+<h2 id="Syntax" name="Syntax">Syntax</h2>
+
+<pre class="eval"><em>removedAttr</em> = <em>element</em>.removeAttributeNode(<em>attributeNode</em>)
+</pre>
+
+<ul>
+ <li><code>attributeNode</code> 是需要被删除的 Attr 节点。</li>
+ <li><code>removedAttr</code> 是被删除了的 Attr 节点。</li>
+</ul>
+
+<h2 id="Example" name="Example">例如</h2>
+
+<pre>// &lt;div id="top" align="center" /&gt;
+var d = document.getElementById("top");
+// getAttributeNode 返回指定元素的指定属性, 返回值是 Attr 节点类型
+var d_align = d.getAttributeNode("align");
+d.removeAttributeNode(d_align);
+// 现在 align 被删除了: &lt;div id="top" /&gt;
+</pre>
+
+<h2 id="Notes" name="Notes">注意</h2>
+
+<p>如果删除有默认值的属性,相当于将属性值替换为默认值。属性只有在具有同样的命名空间、本地名称以及原始前缀时,才会在被删除的时候替换为默认值。</p>
+
+<p>不像 setAttributeNode 和 setAttributeNodeNS 配对使用那样,需要知道要替换哪个现有属性。removeAttributeNode 没有那样的要求,也没有 removeAttributeNodeNS。removeAttributeNode可以删除命名空间以及非命名空间的属性。</p>
+
+<p>{{ DOMAttributeMethods() }}</p>
+
+<h2 id="Specification" name="Specification">规范</h2>
+
+<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198">DOM Level 2 Core: removeAttributeNode</a> (<a class="external" href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-removeAttributeNode">DOM Level 1 Core</a> 里面的介绍)</p>