我有一个如下所示的数据表:
<table><thead>
<tr>
<th><input type="checkbox" /></th>
<th scope="col">Foo</th>
<th scope="col">Bar</th><tr>
</thead>
<tbody>
<tr><td><input type="checkbox" /></td><td scope="row">a</td><td>b</td></tr>
<tr><td><input type="checkbox" /></td><td scope="row">c</td><td>d</td></tr>
</tbody></table>
我希望标题中的复选框选中正文中的所有复选框。我已经编写了 Javascript 来进行选择,它工作正常。然而,在 IE7 和 IE8(可能是其他浏览器,但我们不需要支持任何其他浏览器)中,标题中的复选框永远不会获得选项卡焦点,因此我们失败了 508。
有没有办法在不对所有内容设置 tabindex 的情况下处理这个问题?
最佳答案
正如 Jukka 在评论中所说,所有这些都需要 labels
.没有<label>
表单元素将自动使任何 508 检查失败。这可能是它抛出的真正错误,但我们需要知道正在使用什么工具。
回答您的新问题:
Anyway, the real issue here is not that it doesn't get focus, but that the focus isn't visible. I tried adding a label, and that didn't help, and I tried just adding text to the TD and that didn't help either
大多数浏览器在获得焦点时在所有元素周围放置一个 1 像素的虚线边框。浏览您的样式表,寻找类似 outline: none;
的内容.您应该删除该行或添加新规则以重新获得焦点。
关于html - 508 投诉 "select all"表格标题中的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13588135/