Sets the value of the specified attribute.
Syntax
object.setAttribute(sName, vValue, iFlags)
Parameters
sName Required. String that specifies the name of the attribute.vValue Required. Variant that specifies the string, number, or Boolean to assign to the attribute. iFlags Required. Integer that specifies one of the following flags: 0Default. When the attribute is set, it overwrites any attributes with the same name, regardless of their case.1The case of the attribute that you set is respected when it is set on the object.
1
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.Be careful when spelling attribute names. If you set iFlags to 1 and the sName 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 iFlags 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.
If the specified attribute is not already present, the setAttribute method adds the attribute to the object and sets the value.
Be careful when spelling attribute names. If you set iFlags to 1 and the sName 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 iFlags 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.
Standards Information
This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Applies To
A, ABBR, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HEAD, hn, HR, HTML, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, nextID, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XML, XMP
See Also
getAttribute, hasAttribute