MathMLElement:tabIndex 屬性

Baseline 已廣泛支援

此功能已成熟,並且在眾多裝置和瀏覽器版本上都能正常工作。自 2023 年 1 月以來,它已在各瀏覽器中可用。

MathMLElement 介面的 tabIndex 屬性表示當前 MathML 元素的 tab 順序。

焦點順序如下:

  1. 具有正數 tabIndex 的元素。tabIndex 值相同的元素應按其出現的順序導航。導航從最低 tabIndex 到最高 tabIndex 進行。
  2. 不支援 tabIndex 屬性或支援該屬性但將其值賦為 0 的元素,按其出現的順序導航。

被停用的元素不參與 tab 順序。值不需要是連續的,也不需要從任何特定值開始。它們甚至可以是負數,儘管每個瀏覽器都會修剪非常大的值。

一個整數。

示例

使用 tabIndex 屬性

html
<math id="math1" tabindex="2">
  <msup>
    <mi>a</mi>
    <mn>2</mn>
  </msup>
</math>

<math id="math2">
  <mfrac>
    <mn>1</mn>
    <mn>2</mn>
  </mfrac>
</math>
js
const math1 = document.getElementById("math1");
const math2 = document.getElementById("math2");

// Access and modify the tabIndex
console.log(math1.tabIndex); // 2
math2.tabIndex = 1; // Add math2 to the tab order before math1

// Programmatically focus on an element with negative tabIndex
math1.tabIndex = -1;
math1.focus(); // Works, even though it is not in the tabbing order

結果

規範

規範
HTML
# dom-tabindex

瀏覽器相容性

另見