topless
topless

Reputation: 8221

How to change onfocus attribute with jquery according to tabindex?

I have a list of elements in my page which are ordered with tabindex. What I am looking for is how can I emulate that the tab key was pressed so the focus to move on the next element? I am planning to change focus on my elements in a specific time interval i.e. 1sec by using jquery.

Upvotes: 3

Views: 550

Answers (2)

Alistair Laing
Alistair Laing

Reputation: 973

You could use Ropstah example but trigger the keypress event http://api.jquery.com/trigger/. You can specify which keycode you want "pressed"

Upvotes: 1

Ropstah
Ropstah

Reputation: 17794

Try this:

$('a[href="#your_tab"]').trigger('click')

Edit: I see you are trying to simulate TAB keypress not click mouseclick. This will help you I think: Simulating a tab keypress using JavaScript

Upvotes: 1

Related Questions