Focus on Table row TR for accessiblity

こ雲淡風輕ζ 提交于 2019-12-13 18:04:50

问题


I have a requirement to implement accessibility on table rows. The application should ideally be div based and rows should've been li's, but it is an old application and redesigning is not an option. So am forced to tweak and make it accessible. Could any one of you please help me to get focus on a table row? Is is possible at all?

For e.g: The table below, on tab, should first focus on the first row and then the input inside it. Again tabbing should do the same on the next row.

<table>
<tr>
    <td><input type="textbox" /></td>
    <td>some content</td>
<tr>
<tr>
    <td><input type="textbox" /></td>
    <td>some content</td>
<tr>
<tr>
    <td><input type="textbox" /></td>
    <td>some content</td>
<tr>
</table>

Any help is highly appreciated.


回答1:


I would do this (using jQuery) by $('tr').first().find('input').first().focus() , I did not know however Coomie's solution. I am not sure if his solution with html will work in IE. There are however some issues with focus() and limitation, if you decide to use this solution make sure you have read about jQuery focus()




回答2:


You can focus on elements that are ordinarily unfocusable by assigning a tabindex:

<td tabindex="1">focus on me</td>


来源:https://stackoverflow.com/questions/7103306/focus-on-table-row-tr-for-accessiblity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!