Get the tab order of the first <a> element (index 0) in the document:
Click the button to get the tab order of the first link (index 0) in the document.
<!DOCTYPE html> <html> <body> <a href="https://www.java2s.com/" tabindex="2">Examples</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() {/*from w w w .j a v a 2 s . co m*/ var x = document.getElementsByTagName("A")[0].tabIndex; document.getElementById("demo").innerHTML = x; } </script> </body> </html>