Example 1 — Read ariaRowIndexText
Log the human-readable row label from a header cell.
const el = document.getElementById("role-heading");
console.log(el.ariaRowIndexText); // "Heading row"
// HTML: aria-rowindex="1" aria-rowindextext="Heading row" How It Works
- Find the cell.
getElementByIdreturns the header node. - Read the reflection.
ariaRowIndexTextreturns thearia-rowindextextstring. - Interpret the label. Assistive tech can announce “Heading row” instead of only “1”.
- Missing attribute. If unset, many browsers return
null.

