manas_sharma86
asked on
Anchor tag and Text field Focus
I have a html file :
<html>
<script type="text/javascript" src="keyboard.js" charset="UTF-8"></script>
<body>
<input type="text">
<a href="#">FIRST</a><br>
<a href="#">SECOND</a><br>
<a href="#">THIRD</a><br>
<a href="#">FOURTH</a>
</body>
</html>
and a JS file as well...
Now my question is that when i press tab on the browser it straight away heads to the text field...
I wan't that it should focus straight on the anchor tag instead of the text field..
How is it possible?
<html>
<script type="text/javascript" src="keyboard.js" charset="UTF-8"></script>
<body>
<input type="text">
<a href="#">FIRST</a><br>
<a href="#">SECOND</a><br>
<a href="#">THIRD</a><br>
<a href="#">FOURTH</a>
</body>
</html>
and a JS file as well...
Now my question is that when i press tab on the browser it straight away heads to the text field...
I wan't that it should focus straight on the anchor tag instead of the text field..
How is it possible?
Add tabindex="1" to whichever element you would like the tab key to send you to first.
Here is an example.
<input type="text" name="test"/>
<a href="#test" tabindex="1">Test</a>
<input type="text" name="test2" tabindex="3" />
<input type="text" name="test3" />
<a href="#test2" tabindex="2">Test 2</a>
ASKER
Cool...And if i don't wan't the browser to react to the tab key..Is that possible...
As in if i press tab...then nothing happens?
As in if i press tab...then nothing happens?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.