aria-posinset

aria-posinset 屬性定義了元素在當前一組列表項或樹項中的編號或位置,當並非所有專案都存在於 DOM 中時。

描述

aria-posinset 屬性的縮寫是“集合中的位置”,它定義了元素在整個列表項或樹項集合中的位置,當只有一部分專案存在於 DOM 中時。

如果列表中的所有專案都存在於 DOM 中,則瀏覽器可以計算總數和每個專案的位置,從而使 aria-posinset 變得不必要。當只有一部分集合在 DOM 中時,包含 aria-posinset 以提供有關元素在集合中的位置的資訊,以及 aria-setsize 以告知使用者完整集合中有多少個專案。

以下示例顯示了一個列表框,其中包含元素週期表中 118 個化學元素中的 4 個元素選項。

html
<h2 id="periodic-table">Periodic table of chemical elements</h2>
<ul role="listbox" aria-labelledby="periodic-table">
  <li role="option" aria-setsize="118" aria-posinset="1">Hydrogen</li>
  <li role="option" aria-setsize="118" aria-posinset="3">Lithium</li>
  <li role="option" aria-setsize="118" aria-posinset="11">Sodium</li>
  <li role="option" aria-setsize="118" aria-posinset="19">Potassium</li>
</ul>

每個 aria-posinset 的值都是一個大於或等於 1 且小於或等於集合大小的整數,前提是已知集合大小。

注意:使用 aria-posinset 時,還必須包含 aria-setsize 的值,該值表示整個集合的大小。如果整個集合的大小未知,則將 aria-setsize 設定為“-1”。

對於 menuitemmenuitemcheckboxmenuitemradio,請根據選單中專案的總數設定 aria-posinset 的值,不包括任何分隔符。

feed 中,每個 <article> 元素的 aria-posinset 設定為表示其在提要中的位置的值,並且 aria-setsize 設定為已載入的文章數量或提要中的總數,具體取決於哪個值對使用者更有幫助。

<整數>

大於或等於 1 且小於或等於 aria-setsize 值的整數。

關聯介面

Element.ariaPosInSet

ariaPosInSet 屬性(Element 介面的一部分)反映 aria-posinset 屬性的值。

ElementInternals.ariaPosInSet

ariaPosInSet 屬性(ElementInternals 介面的一部分)反映 aria-posinset 屬性的值。

關聯角色

規範

規範
可訪問的富網際網路應用程式 (WAI-ARIA)
# aria-posinset

另請參閱