HTML DOM tabIndex 属性
定义和用法
tabIndex 属性可设置返回下拉列表中的 tab 键控制次序。
语法
- selectObject.tabIndex=number
实例
下面的例子将显示出一个文本框和一个下拉列表的 tab 键控制次序:
- <html>
- <head>
- <script type="text/javascript">
- function showTabIndex()
- {
- var email=
document.getElementById('email').tabIndex
;- var sex=
document.getElementById('sex').tabIndex
;- document.write("Tab index of email field: " + email);
- document.write("<br />");
- document.write("Tab index of dropdown list: " + sex);
- }
- </script>
- </head>
- <body>
- <form>
- Email: <input type="text" id="email" tabindex="1" />
- <br />
- Sex:
- <select id="sex" tabindex="2">
- <option>Male</option>
- <option>Female</option>
- </select>
- <br /><br />
- <input type="button" onclick="showTabIndex()"
- value="Show tabIndex" />
- </form>
- </body>
- </html>