TOC PREV NEXT INDEX

domref



setAttribute


setAttribute adds a new attribute or changes the value of an existing attribute on the current element.

Syntax

element.setAttribute(name, value)
 

Parameters

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

value is the desired value of the new attribute.

Example

s
d = document.getElementById("d1");
 
d.setAttribute("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

setAttribute
 


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