HTML DOM tabIndex 属性

定义和用法

tabIndex 属性可设置返回下拉列表中的 tab 键控制次序。

语法

  1. selectObject.tabIndex=number

实例

下面的例子将显示出一个文本框和一个下拉列表的 tab 键控制次序:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function showTabIndex()
  5. {
  6. var email=document.getElementById('email').tabIndex;
  7. var sex=document.getElementById('sex').tabIndex;
  8. document.write("Tab index of email field: " + email);
  9. document.write("<br />");
  10. document.write("Tab index of dropdown list: " + sex);
  11. }
  12. </script>
  13. </head>
  14. <body>
  15.  
  16. <form>
  17. Email: <input type="text" id="email" tabindex="1" />
  18. <br />
  19. Sex:
  20. <select id="sex" tabindex="2">
  21. <option>Male</option>
  22. <option>Female</option>
  23. </select>
  24. <br /><br />
  25. <input type="button" onclick="showTabIndex()"
  26. value="Show tabIndex" />
  27. </form>
  28.  
  29. </body>
  30. </html>