Element.setAttributeNS

  • Revision slug: DOM/element.setAttributeNS
  • Revision title: element.setAttributeNS
  • Revision id: 167285
  • Created:
  • Creator: Nickolay
  • Is current revision? No
  • Comment fix specification link

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.setAttribute(namespace, name, value)
  • namespace is the string specifying the namespace of the attribute.
  • name is the 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

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>.setAttribute(<i>namespace</i>, <i>name</i>, <i>value</i>)
</pre>
<ul><li> <code>namespace</code> is the string specifying the namespace of the attribute.
</li><li> <code>name</code> is the 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("http://www.mozilla.org/ns/specialspace", "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>
Revert to this revision