aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/element/setattributenode
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/ja/web/api/element/setattributenode
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/api/element/setattributenode')
-rw-r--r--files/ja/web/api/element/setattributenode/index.html48
1 files changed, 48 insertions, 0 deletions
diff --git a/files/ja/web/api/element/setattributenode/index.html b/files/ja/web/api/element/setattributenode/index.html
new file mode 100644
index 0000000000..d29967758d
--- /dev/null
+++ b/files/ja/web/api/element/setattributenode/index.html
@@ -0,0 +1,48 @@
+---
+title: element.setAttributeNode
+slug: Web/API/Element/setAttributeNode
+tags:
+ - DOM
+ - Gecko
+ - 翻訳中
+translation_of: Web/API/Element/setAttributeNode
+---
+<p>{{ ApiRef("DOM") }}</p>
+
+<h3 id="Summary" name="Summary">Summary</h3>
+
+<p><code>setAttributeNode()</code> adds a new <code>Attr</code> node to the specified element.</p>
+
+<h3 id="Syntax" name="Syntax">Syntax</h3>
+
+<pre class="eval"><em>replacedAttr</em> =<em>element</em>.setAttributeNode(<em>attribute</em>)
+</pre>
+
+<ul>
+ <li><code>attribute</code> is the <code>Attr</code> node to set on the element.</li>
+ <li><code>replacedAttr</code> is the replaced attribute node, if any, returned by this function.</li>
+</ul>
+
+<h3 id="Example" name="Example">Example</h3>
+
+<pre>// &lt;div id="one" align="left"&gt;one&lt;/div&gt;
+// &lt;div id="two"&gt;two&lt;/div&gt;
+var d1 = document.getElementById("one");
+var d2 = document.getElementById("two");
+var a = d1.getAttributeNode("align");
+d2.setAttributeNode(a);
+alert(d2.attributes[1].value)
+// returns: `left'
+</pre>
+
+<h3 id="Notes" name="Notes">Notes</h3>
+
+<p>If the attribute named already exists on the element, that attribute is replaced with the new one and the replaced one is returned.</p>
+
+<p>This method is seldom used, with <code><a href="ja/DOM/element.setAttribute">setAttribute()</a></code> usually being used to change element's attributes.</p>
+
+<p>{{ DOMAttributeMethods() }}</p>
+
+<h3 id="Specification" name="Specification">Specification</h3>
+
+<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-887236154">DOM Level 2 Core: setAttributeNode</a> (introduced in <a class="external" href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-setAttributeNode">DOM Level 1 Core</a>)</p>