Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip input when press tab

Tags:

html

I have a form where there are three input boxes with three drop down select tags beside them. I want to be able to press the tab key and go from one input to another, but you have to press it twice because it goes to the drop down menu after the input box. Is there a way I can make it "skip over" the drop down menu and go right to the next input box when you press tab?

like image 290
eshellborn Avatar asked Nov 17 '12 22:11

eshellborn


People also ask

How do you skip focus in HTML?

The tabindex attribute controls tabbing. Set it to -1 and the tab key will not stop on that element. Set it to a non-negative number and you can control the tab order.

What is Tabindex CSS?

The tabindex attribute specifies the tab order of an element (when the "tab" button is used for navigating). The tabindex attribute can be used on any HTML element (it will validate on any HTML element.


2 Answers

tabindex=0 property makes inputs skippable in case when other inputs have tabindex values above zero.

tabindex="-1" makes input completely skippable

like image 61
el Dude Avatar answered Sep 29 '22 08:09

el Dude


You can specify the tabbing order explicitly by setting the [tabindex] attribute:

without [tabindex]:
<input type="text" />     <!-- first --> <input type="checkbox" /> <!-- second --> <select>...</select>      <!-- third --> 
with [tabindex]:
<input type="text" tabindex="1" />      <!-- first --> <input type="checkbox" tabindex="3" /> <!-- third --> <select tabindex="2">...</select>      <!-- second --> 
like image 26
zzzzBov Avatar answered Sep 29 '22 06:09

zzzzBov