Element.setAttributeNS

  • Revision slug: DOM/element.setAttributeNS
  • Revision title: element.setAttributeNS
  • Revision id: 167289
  • Created:
  • Creator: Mgjbot
  • Is current revision? No
  • Comment robot Adding: [[fr:DOM:element.setAttributeNS]] <<langbot>>

Revision Content

{{template.DomRef()}}

Summary

setAttributeNS adds a new attribute or changes the value of an attribute with the given namespace and name.

Syntax

element.setAttributeNS(namespace, name, value)
  • namespace is a string specifying the namespace of the attribute.
  • name is a string identifying the attribute to be set.
  • value is the desired string value of the new attribute.

Example

var d = document.getElementById("d1"); 
d.setAttributeNS("http://www.mozilla.org/ns/specialspace", "align", "center");

Notes

{{template.DOMAttributeMethods()}}

Specification

DOM Level 2 Core: setAttributeNS

{{ wiki.languages( { "fr": "fr/DOM/element.setAttributeNS", "pl": "pl/DOM/element.setAttributeNS" } ) }}

Revision Source

<p>
{{template.DomRef()}}
</p>
<h3 name="Summary"> Summary </h3>
<p><code>setAttributeNS</code> adds a new attribute or changes the value of an attribute with the given namespace and name. 
</p>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval"><i>element</i>.setAttributeNS(<i>namespace</i>, <i>name</i>, <i>value</i>)
</pre>
<ul><li> <code>namespace</code> is a string specifying the namespace of the attribute.
</li><li> <code>name</code> is a string identifying the attribute to be set.
</li><li> <code>value</code> is the desired string value of the new attribute.
</li></ul>
<h3 name="Example"> Example </h3>
<pre class="eval">var d = document.getElementById("d1"); 
d.setAttributeNS("<span class="plain">http://www.mozilla.org/ns/specialspace</span>", "align", "center");
</pre>
<h3 name="Notes"> Notes </h3>
<p>{{template.DOMAttributeMethods()}}
</p>
<h3 name="Specification"> Specification </h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-ElSetAttrNS">DOM Level 2 Core: setAttributeNS</a>
</p>
<div class="noinclude">
</div>
{{ wiki.languages( { "fr": "fr/DOM/element.setAttributeNS", "pl": "pl/DOM/element.setAttributeNS" } ) }}
Revert to this revision