While it's true that some of the properties on element instances are direct reflections of attributes (the rel
property directly reflects the rel
attribute on link
elements, for instance, and className
directly reflects the class
attribute), but this isn't always the case.
The value
property is not a direct reflection of the value
attribute. It gets its initial value from the attribute, but setting it doesn't affect the attribute (which is still available both through getAttribute
and the defaultValue
property). (There are others that aren't direct reflections; the href
property on a
elements gives you the absolute path, but the href
attribute may be a relative path.)
If you want to set the attribute, use setAttribute
. (And test carefully on any versions of IE you want to support, as Microsoft has a history of getting this wrong.)