Javascript examples for DOM:Element tabIndex
The tabIndex property sets or gets the tabindex attribute of an element.
The tabindex attribute sets the tab order of an element (when the "tab" button is used for navigating).
Set the tabIndex property with the following Values
Value | Description |
---|---|
number | Sets the tabbing order of the element (1 is first). |
If the number is negative, the element will be removed from the tab order
A Number, representing the tab order of the element
The following code shows how to change the tab order for three links:
<!DOCTYPE html> <html> <body> <a href="https://www.java2s.com/" tabindex="2">java2s.com</a><br> <a href="http://www.google.com/" tabindex="1">Google</a><br> <a href="http://www.microsoft.com/" tabindex="3">Microsoft</a> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* ww w .java 2 s .co m*/ document.getElementsByTagName("A")[0].tabIndex = 2; } </script> </body> </html>