Seeker
Seeker

Reputation: 2475

Avoid focus to go beyond a particular button using tab button

Lets take a scenario, where in I have a series of buttons btn1, btn2, btn3...

I kept pressing 'tab' key and my focus is on btn2. Now I want to avoid btn3 or any other beyond btn2 not to get focus on tab key press.

How can I achieve this?

Upvotes: 0

Views: 1127

Answers (1)

Amrendra
Amrendra

Reputation: 2077

The behaviour of the tab key can be changed with the tabindex attribute. It is the order the elements will have the focus.

With

    <button id="1" tabindex="-1">Some content</button> 

you should prevent the focus to be on your button.

or like this:

 $(".btnclass").attr("tabindex", "-1");

check this:http://www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.html

Upvotes: 5

Related Questions