jqueryhtmlaccessibilitytabindexkeyboard-navigation

Is there a way to make all onclick elements navigateable by keyboard?


With links and form fields you can use tab to cycle trough and activate them.

In my code however I use lots of elements, that have an onclick attribute to perform different actions. For example a table, where each tr is clickable and expands on click.

Now I want my page to be browseable by keyboard only as well.

I was thinking about setting tabindex on each tr, which worked in Firefox (I was able to tab through the items, but not click them), but did not in Chrome.

How can I cycle through all elements containing onclick using the keyboard? If not with plain HTML, maybe with JQuery.


Solution

  • I'd recommend that you simply wrap the elements in anchor tags (<a>).