html - 如何使可点击的 <tr> 可访问?

标签 html accessibility wai-aria

我有一个表,其中每个 <tr>打开<tr>在它下面。 我怎样才能让用户可以访问它 这样他们就可以知道<tr>是可点击的,将打开 <tr>在它下面?

例子:

<table>
    <thead>
        <tr>
            <th>bla1</th>
            <th>bla2</th>
        </tr>
    </thead>
    <tbody>
        <tr class="infoBlock" data-id="t1">
            <td></td>
            <td></td>
        </tr>
        <tr class="detailsBlock" data-id="t1">
            <td></td>
            <td></td>
        </tr>
        <tr class="infoBlock" data-id="t2">
            <td></td>
            <td></td>
        </tr>
        <tr class="detailsBlock" data-id="t2">
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>

用户(使用屏幕阅读器的人)需要知道他们何时点击

<tr class="infoBlock" data-id="t1"> 

打开

<tr class="detailsBlock" data-id="t1"> 

我知道 aria-expanded属性可用于 <button><a> . https://www.w3.org/WAI/GL/wiki/Using_the_WAI-ARIA_aria-expanded_state_to_mark_expandable_and_collapsible_regions

最佳答案

您可以使用 data- attribute在表格行上。

<tr tabindex="0" role=button data-bind="click: SelectOnClick, event: {keypress: SelectOnKeyup}">

关于html - 如何使可点击的 <tr> 可访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46304508/

相关文章:

HTML ARIA 验证问题 (HTML5)

html - 只有嵌套在 anchor 中的 div 的上半部分是可点击的

html - CSS:div 中的段落与 div 文本出现在同一行

html - CSS缓存问题

ios - 相机快照按钮的辅助功能标签是什么?

html - 您可以在 <section role ="main"> 元素中使用 <aside> 元素吗?

html - 带有文本的 Div 和其中填充的 3 个 div

html - anchor 标签有 :focus style applied on click

html - Achecker 链接文本可能没有意义

html - 什么是 HTML5 咏叹调?