Reputation: 938
Is it possible to somehow make it so that when you are in the url bar of your browser and you press TAB you go to the first inputfield on your page and not your bookmarks or something else?
Using focus() could somehow be a workaround but it's not what I am looking for.
So focus is in URL bar, user presses TAB, focus goes to the first input field :)
Thanks in advance.
Upvotes: 0
Views: 383
Reputation: 201588
Yes, you can do that by setting tabindex
attributes, like you set any other attributes. If you wish to do that in scripting, and not directly in HTML, you just use the attr()
method.
The details depend on the page structure and desired behavior, and you need to understand how the tabindex
attributes specify the tabbing order. Consider a very simple case, where you have just a <div class=nav>
containing navigational links and another part of the page containing input
fields. Suppose you want the fields to be tabbed first, and only after them the navigation links. You can then write:
$('input').attr('tabindex', 1);
$('.nav a').attr('tabindex', 10000);
It’s that simple in a simple case, since elements sharing the same tabindex
value are tabbed in the order in which they appear in HTML source.
Upvotes: 0
Reputation: 103348
This isn't possible with jQuery as you are trying to change the "tab index" of your browser software. This is outside the contraints of jQuery. Ie. Its outside of the DOM.
If there is a way of changing it, I doubt it is possible to do this cross-browser, and would probably be only possible for your particular instance of your browser software.
Upvotes: 1