Chrome 21 不检查单选按钮 [英] Chrome 21 not checking radio buttons
问题描述
我经过一番努力才弄清楚这一点,所以我想我会分享我所遇到的,以便其他人可以从我的努力中受益.Firefox IE 和 chrome 19(我手头唯一的其他版本)对此没有问题,但 chrome 21 有.
I figured this out after much effort so I thought I'd share what I came across, so others can benefit from my effort. Firefox IE and chrome 19 (the only other version I have handy) don't have a problem with this, but chrome 21 does.
如果你有这个单选按钮
<input type='radio' name'k1' value='v1' checked>
如果它位于无效位置,它将不会在页面上显示为选中状态.
it will not appear checked on the page if it's in an invalid location.
例如我有
<table>
<input type='radio' name'k1' value='v1' checked>
<tr><td>table information</td></tr>
</table>
无论我做什么,页面加载时都不会显示为选中状态.
and no matter what I did, it wouldn't appear checked when the page loaded.
推荐答案
在 Google Chrome 21.0.1180.75 和 .79 上测试
Tested on Google Chrome 21.0.1180.75 and .79
<table>
<input type="checkbox" name="n" value="v" checked="checked" />
</table>
缺少输入元素周围的 <tr><td></tr></td>
会导致 checked
复选框不显示为已选中.此外,当提交表单时,这些复选框也不会被检查到服务器端!
Missing the <tr><td></tr></td>
around the input element causes checked
checkboxes not to appear as checked. Additionally, when the form is submitted, those checkboxes don't come to the server-side as being checked, either!
一旦 html 格式正确,复选框应显示为选中状态,如 checked
属性所示:
Once the html is formatted properly, the checkboxes should appear checked as indicated by the checked
attribute:
<table>
<tr>
<td>
<input type="checkbox" name="n" value="v" checked="checked" />
</td>
</tr>
</table>
这篇关于Chrome 21 不检查单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!