How to change input field switch sequence (swithcing input field using Tab key) on a web page?

StackOverflow https://stackoverflow.com/questions/7455865

Question

On a web page, if there are input fields, pressing Tab key switches them, but in a particular order, is there a way to change this order and set it to some different order?

If this can be done in html, it is preferable, but if some other scripting language (javascript etc) can do it, it is also acceptable.

Était-ce utile?

La solution

The attribute tabindex takes care of that http://www.w3.org/TR/WCAG-TECHS/H4.html to exclude a element completely from the tabindex give it a index of -1 the lowest safe index to start with is 1.

0 is the default value so should be avoided when explicitly setting the tabindex

<input tabindex=1 type="text" name="my_input1">
<input tabindex=3 type="text" name="my_input2">
<input tabindex=2 type="text" name="my_input3">

The tab would go from the my_input1 to my_input3 to my_input2 field in this example

tabindex may be used on a, area, button, input, object, select and textarea

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top