22

On an HTML form I have INPUT text box followed by a link, then followed by another INPUT text box. I want to remove the link from the tabindex / tab order:

<p>
<input type="text" name="field1" id="field1" value="" />
<a href="..a url.." id="link1">more info</a>
</p>

<p>
<input type="text" name="field2" id="field2" value="" />
</p>

The tab order is field1, link1, field2 and I want it to be field1, field2 without link1 in the tabindex / order at all. Aside from reordering via the tabindex attribute, is there any way to remove link1 from tabbing altogether?

leepowers
  • 37,828
  • 23
  • 98
  • 129

1 Answers1

36

You can achieve this with html:

<p>
<input type="text" name="field1" id="field1" value="" />
<a href="#" id="link1" tabindex="-1">more info</a>
</p>

<p>
<input type="text" name="field2" id="field2" value="" />
</p>

You could also use jquery to do this:

$('#link1').prop('tabIndex', -1);
Timo Tijhof
  • 10,032
  • 6
  • 34
  • 48
Jage
  • 7,990
  • 3
  • 32
  • 31
  • 1
    It works and it resolves a problem I have, but will it validate/is it crossbrowser compatible.? W3 says tabindex should be between 0 and 32767..? – pnichols Sep 21 '10 at 20:43
  • 3
    It validates using transitional doctype (I didn't check any others) and worked in FF, safari, chrome, opera, and IE 6,7,8. – Jage Sep 22 '10 at 19:07