How to notify screen readers using WAI-ARIA that a div is now visible

前端 未结 4 1708
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 20:47

How do you notify screen readers using WAI-ARIA that a div is now visible?

If we got the html

Present main content
4条回答
  •  北海茫月
    2020-12-13 21:18

    Use aria-hidden

    Indicates that the element and all of its descendants are not visible or perceivable to any user as implemented by the author. See related aria-disabled.

    If an element is only visible after some user action, authors MUST set the aria-hidden attribute to true. When the element is presented, authors MUST set the aria-hidden attribute to false or remove the attribute, indicating that the element is visible. Some assistive technologies access WAI-ARIA information directly through the DOM and not through platform accessibility supported by the browser. Authors MUST set aria-hidden="true" on content that is not displayed, regardless of the mechanism used to hide it. This allows assistive technologies or user agents to properly skip hidden elements in the document.

    so your code could become

    $('#foo').hide().attr('aria-hidden', 'true');
    $('#bar').show().attr('aria-hidden', 'false');
    

提交回复
热议问题