tabindex 全局屬性 指示其元素是否可以聚焦,以及它是否/在何處參與順序鍵盤導(dǎo)航(通常使用Tab鍵,因此得名)。
注:tabindex 的最大值不應(yīng)超過 32767。如果沒有指定,它的默認值為 -1。
以指定的tabindex順序鏈接:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML tabindex 屬性的使用(菜鳥教程 cainiaoplus.com)</title>
</head>
<body>
<div tabindex="1">(cainiaoplus.com)</div><br>
<div tabindex="3">google.com</div><br>
<div tabindex="2">microsoft.com</div>
<script>
// At start, set focus on the first div
document.getElementsByTagName('div')[0].focus();
</script>
<p tabindex="4"><b>Note:</b> Try navigating the elements by using the "Tab" button on your keyboard.</p>
</body>
</html>測試看看 ?/?IEFirefoxOperaChromeSafari
所有主流瀏覽器都支持 tabindex 屬性
tabindex屬性指定元素的選項卡順序(使用“ tab”按鈕進行導(dǎo)航時)。
在HTML 4.01中,tabindex屬性可以與<a>,<area>,<button>,<input>,<object>,<select>和<textarea>一起使用。
<element tabindex="number">
| 值 | 描述 |
|---|---|
| number | 規(guī)定元素的 tab 鍵控制順序(1 是第一)。 |