在 HTML5 中选中和取消选中复选框的正确方法是什么? [英] What is the proper way to check and uncheck a checkbox in HTML5?
问题描述
查看了 HTML 规范,但无法理解它:http://www.w3.org/TR/html5/the-input-element.html#attr-input-checked
Looked at the HTML spec, but couldn't make heads or tails of it: http://www.w3.org/TR/html5/the-input-element.html#attr-input-checked
在 HTML(非动态)中检查复选框的正确方法是什么?
What is the correct way to check a checkbox in HTML (not dynamically)?
checked="true"
checked="checked"
取消选中复选框的正确方法是什么?
What is the correct way to uncheck a checkbox?
<input type="checkbox" /> with no checked attribute
checked="false"
checked="none"
在哪里检查 HTML 规范以选中/取消选中复选框?
Where to check the HTML specification to check/uncheck a checkbox?
推荐答案
<input type="checkbox" checked="checked" />
或者干脆
<input type="checkbox" checked />
对于选中的复选框.未选中的复选框没有选中的属性 ().
for checked checkbox.
No checked attribute (<input type="checkbox" />
) for unchecked checkbox.
参考:http://www.w3.org/TR/html-markup/input.checkbox.html#input.checkbox.attrs.checked
这篇关于在 HTML5 中选中和取消选中复选框的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!