Possible Duplicate:
JavaScript setAttribute vs .attribute=
Should I prefer one of these two methods to add attributes?
input.name='amount';
input.setAttribute('name', 'amount');
Possible Duplicate:
JavaScript setAttribute vs .attribute=
Should I prefer one of these two methods to add attributes?
input.name='amount';
input.setAttribute('name', 'amount');
From MDN:
Using setAttribute() to modify certain attributes, most notably value in XUL, works inconsistently, as the attribute specifies the default value. To access or modify the current values, you should use the properties. For example, use elt.value instead of elt.setAttribute('value', val).
I guess it would be better to access attributes directly, since that is what the DOM is designed for...
Mozilla supports only setAttribute(). So if you are designing a multi-browser supporting page, it will be good to have an if condition checking the Browser Name, and call the function/assignments as per that.