I want to uncheck my Checkbox with Javascript, but it didn't work. And then I tried to set the checked property to false directly in HTML, but not even that worked: (I tried checked="false" too...)
My HTML:
<input type="checkbox" id="dateCheckbox" checked=false >
<label for="dateCheckbox"> Keinen Zeitraum angeben</label>
Result:

Why is it still checked?
HTML5 does not use true or false for boolean attributes. Boolean attributes are true by specifying the attribute name alone, and a false value is the omission of the attribute.
(For XHTML5, you provide the attribute-name as the value in order to conform to XML's rules for attributes):
So for an unchecked checkbox, change this:
<input type="checkbox" id="dateCheckbox" checked=false >
To this (HTML5 and XHTML5):
<input type="checkbox" id="dateCheckbox">
For a checked checkbox, change this:
<input type="checkbox" id="dateCheckbox" checked=true >
To this (HTML5):
<input type="checkbox" id="dateCheckbox" checked>
or this (XHTML5):
<input type="checkbox" id="dateCheckbox" checked="checked" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With