简体   繁体   English

设置aria-live以读取更新,然后重点读取DOM元素

[英]Set aria-live to read updates before reading out the DOM element in focus

Suppose you have a aria-live region and it is read out every time some change is made. 假设您有一个咏叹调活动区域,并且每次进行一些更改时都会读出该区域。 But every time the change is made, the focus moves to a particular form element First Name . 但是每次进行更改时,焦点便移至特定的表单元素First Name

If the text being updated in aria-live region is Loading complete , the preferred reading sequence is Loading complete First name , ie first the aria-live region and then the element being focused. 如果要在aria-live区域中更新的文本为Loading complete ,则首选阅读顺序为Loading complete First name ,即首先是aria-live区域,然后是要聚焦的元素。

However, regardless of the politeness setting of aria-live, I can't seem to get that combination. 但是,无论aria-live的礼貌设置如何,我似乎都无法做到这一点。

if aria-live = assertive or aria-live = polite , it reads First name Loading complete 如果aria-live = assertivearia-live = polite ,则其显示为First name Loading complete

if aria-live = rude , it only reads Loading complete , ignoring reading of the element being focused. 如果aria-live = rude ,则仅读取Loading complete ,而忽略读取正在关注的元素。

How do I make this precedence order? 如何制定优先顺序?

I am using JavaScript to manipulate the contents. 我正在使用JavaScript处理内容。

I've faced a very similar problem in the past. 过去我也遇到过类似的问题。 Not sure if this is what you are looking for, but a timeout helped me. 不确定这是否是您要的内容,但是超时帮助了我。 So essentially the code looks like: 因此,基本上,代码如下所示:

// ...
// perform updates to your live region
// ...
setTimeout(function() {
    $('.autofocus').focus();
});

ARIA has been a mystery to me, and still is, so can't really explain why this would work, but it did for me anyway. ARIA一直是我的一个谜,现在仍然如此,因此无法真正解释为什么会奏效,但无论如何对我来说还是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM