简体   繁体   中英

How to restrict screen reader to not read a certain text?

Imagine, I have a <div> with aria-label as "Read this" ( aria-label is added at runtime). Inside the <div> , I have a <span> with text "do not read this".

Now what Jaws is doing is, it reads both the text ("Read this" and "do not read this").

<div aria-label="Read this">
  <span>Do not read this</span>
</div>

The expectation is to only read "Read this". Is there anyway to restrict screen readers to force stop reading a text?

aria-hidden="true" is the thing you want

<div aria-label="Read this">
<span aria-hidden="true">Do not read this</span>
</div>

Note that not all screenreaders will read the aria-label on a div element and that it will result in a blank element

works for JAWS 2018, chrome 72:

 <div role="text" aria-label="Read this"> Do not read this </div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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