I have set the html checkbox the checked property

2019-02-16 09:00发布

问题:

here is my html markup:

<input type="checkbox" checked="false">

I have set the checked to false, but the result is still checked

Why this happened? If I remove the checked property, it would turn unchecked.

Actually I want insert a input[type=checkbox] into html markup in dynamic, with parameter to determine checked or not

回答1:

If you specify checked, then it is checked; it doesn't matter if you say checked="false", checked="true", checked="checked" or just plain checked.

If you don't want it checked, then do not include the checked attribute.

<input type="checkbox" />

See: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_checked