Input Checkbox checked by default

后端 未结 5 1246
清酒与你
清酒与你 2021-02-18 16:12

For the life of me I cant set my CheckBox to checked at page load. I have tried adding value=\"true\" and Checked=\"checked\" after id and still noth

5条回答
  •  不思量自难忘°
    2021-02-18 16:39

    You're looking for the checked content attribute. Here's the relevant snippet from the official documentation: (Living Standard):

    The checked content attribute is a boolean attribute that gives the default checkedness of the input element. When the checked content attribute is added, if the control does not have dirty checkedness, the user agent must set the checkedness of the element to true; when the checked content attribute is removed, if the control does not have dirty checkedness, the user agent must set the checkedness of the element to false.

    Note the docs have links to definition of relevant terms.

    If it seems too technical, you can always go to MDN page on checked. MDN contributors have put up considerable effort into "translating" HTML Standard into more readable/understandable form (often times with examples), especially useful to people without a solid foundation on web related terminology and concepts.

    Note: You'll also find the direct answer to your question on MDN.

提交回复
热议问题