[whatwg] Value attribute

Olav Junker Kjær olav at olav.dk
Thu Feb 24 06:18:16 PST 2005


Matthew Raymond wrote:
>    In general, if you set a DOM property, it won't set the actual 
> attribute in markup. In order to change the markup, I think you have to 
> use the setAttribute method. However, I believe that the setAttribute 
> method does change the DOM property.

Did a quick test: In Mozilla, IE and Opera setting an ordinary attribute 
through a DOM property seems to be equivalent to using setAttribute. The 
"value" property is handled differently though. In IE and Opera 
getAttribute("value") returns the same as the "value" DOM property, 
while in Mozilla it returns the same as the defaultValue property (which 
is the correct behavior, I think). However, using innerHTML in Opera 
seem to serialize the element correctly by using the defaultValue 
property as at content of the value HTML, as does Mozilla.

Anyway, your original statment that DOM Range couldn't work on the 
current value in an input field seems to be correct. The DOM Range may 
work on an Attr node but not any DOM attribute. The current value is in 
the DOM in the form of an property, but not in the form of a DOM Attr node.

regards
Olav



More information about the whatwg mailing list