2.3.2.5 setAttribute
Sets the value of the specified attribute.
Syntax
-
object.setAttribute(sAttrName, vValue [, iCaseSensitive])
Parameters
sAttrNameof type DOMString
A required string that specifies the name of the attribute.
vValueof type DOMString
The value to assign to the attribute.
iCaseSensitiveof type Integer
An optional integer that specifies whether to use a case-sensitive search to locate the attribute. Can be one of the following values:
1
The case of sAttrName
is
respected.
0
Match sAttrName
regardless of
case.
Return Value
No return value.
Remarks
If the specified attribute is not already present, the setAttribute method adds the attribute to the object and sets the value.
If your pages are displayed in IE7 mode, be careful when spelling attribute names. If you set iCaseSensitive to 1 and the sAttrName parameter does not have the same uppercase and lowercase letters as the attribute, a new attribute is created for the object. If two or more attributes have the same name, differing only in case, and iCaseSensitive is set to 0, this method assigns values only to the first attribute created with this name. All other attributes of the same name are ignored.