[whatwg] boolean attributes in javascript

Garrett Smith dhtmlkitchen at gmail.com
Tue Dec 8 17:40:04 PST 2009

On Tue, Dec 8, 2009 at 4:49 PM, Dean Edwards <dean.edwards at gmail.com> wrote:
> On 08/12/2009 23:04, Garrett Smith wrote:
>> Setting an attribute to the empty string may have the effect of
>> removing the attribute in some browsers.
> Which browsers/properties?

s/removing the attribute/setting a false value.

Try setting a 'checked' property of an input checkbox in IE.

<input type="checkbox" checked id="checkboxInput">

checkboxInput.setAttribute("checked", "");

will un-check a checkbox in IE.

The phenomenon is explained by two factors:
1) In IE < 8, attributes are properties (IE8 has some fixes)
2) Setting a boolean property to a non-boolean value may result in
boolean conversion.

More information about the whatwg mailing list