The tabIndex property sets or gets the value of the tabindex attribute of an element.
Change the tab order for three links:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor1" href="https://www.java2s.com">Link 1</a></p> <p><a id="myAnchor2" href="https://www.java2s.com">Link 2</a></p> <p><a id="myAnchor3" href="https://www.java2s.com">Link 3</a></p> <input type="button" onclick="myFunction()" value="Change TabIndex"> <script> function myFunction() {// www . j a va 2 s . co m document.getElementById("myAnchor1").tabIndex = "3"; document.getElementById("myAnchor2").tabIndex = "2"; document.getElementById("myAnchor3").tabIndex = "1"; } </script> </body> </html>
The tabindex attribute specifies the tab order of an element.
Property Values
Value | Description |
---|---|
number | Specifies the tabbing order of the element (1 is first). |
If the number is negative, the element will be removed from the tab order
The tabIndex property returns a Number representing the tab order of the element.