HTML DOM tabIndex 属性

定义和用法

tabIndex 属性可设置或返回按钮的 tab 键控制次序。

语法

  1. buttonObject.tabIndex=tabIndex

实例

下面的例子可返回按钮的 tab 键控制次序:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function showTabIndex()
  5. {
  6. var b1=document.getElementById('b1').tabIndex;
  7. var b2=document.getElementById('b2').tabIndex;
  8. var b3=document.getElementById('b3').tabIndex;
  9. document.write("Tab index of Button 1: " + b1);
  10. document.write("<br />");
  11. document.write("Tab index of Button 2: " + b2);
  12. document.write("<br />");
  13. document.write("Tab index of Button 3: " + b3);
  14. }
  15. </script>
  16. </head>
  17. <body>
  18.  
  19. <button id="b1" tabIndex="1">Button 1</button><br />
  20. <button id="b2" tabIndex="2">Button 2</button><br />
  21. <button id="b3" tabIndex="3">Button 3</button><br />
  22. <br />
  23. <input type="button" onclick="showTabIndex()"
  24. value="Show tabIndex" />
  25.  
  26. </body>
  27. </html>