大网数据广告活动
Web 标准与前端开发

Element: ariaFlowToElements property

· 52CE 我爱测

The **`ariaFlowToElements`** property of the Element interface is an array containing the element (or elements) that provide an alternate reading order of content, overriding the general default reading order at the user's discretion. If just one element is provided this is the n

DOM

The ariaFlowToElements property of the Element interface is an array containing the element (or elements) that provide an alternate reading order of content, overriding the general default reading order at the user's discretion. If just one element is provided this is the next element in the reading order. If multiple elements are provided, then each element represents a possible path that should be offered to the user for selection.

The aria-flowto topic contains additional information about how the attribute and property should be used.

Value

An array of subclasses of HTMLElement.

When read, the returned array is static and read-only. When written, the assigned array is copied: subsequent changes to the array do not affect the value of the property.

Description

The property is a flexible alternative to using the aria-flowto attribute to set an alternative reading order. Unlike aria-flowto, the elements assigned to this property do not have to have an id attribute.

The property reflects the element's aria-flowto attribute when it is defined, but only for listed reference id values that match valid in-scope elements. If the property is set, then the corresponding attribute is cleared. For more information about reflected element references and scope see Reflected element references in the Reflected attributes guide.

Examples

Get the flow-to element

This example demonstrates the normal flow through three elements section1, section2, section3 in order, and an alternative order that jumps from section1 to section3, and back again. Note that the example is illustrative unless you have accessibility tools running: we don't actually follow this alternate path.

HTML

The HTML defines three div elements that define sections, with a class "section", and id values: section1, section2, and section3. Each section has a normal flow defined by it's order, starting from section1 and ending at section3. An alternative flow is defined in sections 1 and 3 using the aria-flowto attribute.

<pre id="log"></pre>
#log {
  height: 200px;
  overflow: scroll;
  padding: 0.5rem;
  margin: 5px;
  border: 1px solid black;
}
<div id="section1" class="section" aria-flowto="section3">
  <h2>Section 1</h2>
  <p>First section in normal flow. Section 3 is alternate flow.</p>
  <a href="#section2">Jump to Section 2 (normal flow)</a>
</div>

<div id="section2" class="section">
  <h2>Section 2</h2>
  <p>Second section in normal flow.</p>
  <a href="#section3">Jump to Section 3 (normal flow)</a>
</div>

<div id="section3" class="section" aria-flowto="section1">
  <h2>Section 3</h2>
  <p>
    Third section in normal flow (end of flow). Section 1 is alternate flow.
  </p>
</div>

JavaScript

The code first checks whether the ariaFlowToElements is supported, and if so, logs its value. It then iterates through the sections, logging the section id, aria-flowto attribute value, and ariaFlowToElements property value.

const logElement = document.querySelector("#log");
function log(text) {
  logElement.innerText = `${logElement.innerText}${text}\n`;
  logElement.scrollTop = logElement.scrollHeight;
}
// Feature test for ariaFlowToElements
if ("ariaFlowToElements" in Element.prototype) {
  const sections = document.querySelectorAll(".section");
  sections.forEach((sectionDivElement) => {
    log(`${sectionDivElement.id}`);
    log(` aria-flowto: ${sectionDivElement.getAttribute("aria-flowto")}`);
    log(" ariaFlowToElements:");
    // Get the ids of each of the elements in the array
    sectionDivElement.ariaFlowToElements?.forEach((elem) => {
      log(`  id: ${elem.id}`);
    });
  });
} else {
  log("element.ariaFlowToElements: not supported by browser");
}

Result

The log below shows each of the sections (identified by id) and the corresponding flow-to element ids that might be selected by accessibility tools. We note here that the attribute and property identify the same flow-to elements.

Get the flow-to element

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。