TOC PREV NEXT INDEX

domref



setAttributeNS


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

Syntax

element.setAttribute(namespace, name, value)
 

Parameters

namespace is the namespace of the new attribute as a string.

name is the name of the new attribute as a string.

value is the desired value of the new attribute.

Example

This example splits the text in a paragraph element. The new, second child of p2 is the sibling node hat contains the text after the split. data gets the text from the text object.

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

 

Notes

If the attribute named already exists, then the value of that attribute is changed to the value passed in as part of this function. If it does not exist, then a new attribute node is created.

Specification

setAttributeNS
 


Netscape Communications
http://developer.netscape.com
TOC PREV NEXT INDEX