开发者

Focus on Table row TR for accessiblity

开发者 https://www.devze.com 2023-03-28 17:57 出处:网络
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

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.


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

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


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()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号