Javascript Reference - HTML DOM tabIndex Property








The tabIndex property sets or gets the tab order for an element.

Syntax

HTMLElementObject.tabIndex=tabIndex

Browser Support

tabIndex Yes Yes Yes Yes Yes

Example

The following code shows how to change the tab order for three links.


<!DOCTYPE html>
<html>
<head>
<script>
function changeTabIndex()<!--   ww w.jav a 2 s  . co  m-->
{
    document.getElementById('1').tabIndex="3";
    document.getElementById('2').tabIndex="2";
    document.getElementById('3').tabIndex="1";
}
</script>
</head>
<body>
<p><a id="1" href="http://www.example.com">1</a></p>
<p><a id="2" href="http://www.example.com">2</a></p>
<p><a id="3" href="http://www.example.com">3</a></p>

<input type="button" onclick="changeTabIndex()"
value="Change TabIndex">

</body>
</html>

The code above is rendered as follows: