jquery – 什么是布尔属性的语法,例如 复选框,在HTML中?

前端之家收集整理的这篇文章主要介绍了jquery – 什么是布尔属性的语法,例如 复选框,在HTML中?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
听起来像一个愚蠢的问题,但我想知道什么是最好的方式说明复选框在HTML中选中/取消选中。

我看过很多不同的例子:

<input type="checkBox" checked="checked" />
<input type="checkBox"  />

<input type="checkBox" checked="yes" />
<input type="checkBox" checked="no" />

<input type="checkBox" checked="true" />
<input type="checkBox" checked="false" />

哪些浏览器与这些中的哪些,以及最重要的是,jQuery弄清楚哪个框被检查所有3?

编辑:
W3C规范似乎暗示只有那里检查的attr是正确的。这是否意味着checked =“false”和checked =“no”仍然会检查框?

解决方法

在HTML中:
<input type="checkBox" checked>
<input type="checkBox" checked="checked">

对于XHTML,您必须使用属性/值匹配对:

<input type="checkBox" checked="checked" />
原文链接:https://www.f2er.com/jquery/183646.html

猜你在找的jQuery相关文章