您好,所有的无障碍Maven,
我想让这个button
元素,当标签打开时,会触发input
元素的屏幕读取。
我试着将aria-labelledby
从button
指向input
,以便读出input
的aria-label
。但是当标签打开时,button
仍然读出它自己的描述。
<fieldset>
<input type="radio" id="inputid" aria-label="read me">
<button aria-labelledby="inputid">don't read me</button>
</fieldset>
是否有办法读取另一个元素的内容?
谢谢你的好意,
2022年12月6日编辑:根据Andy的评论,input
元素只是在视觉上隐藏了,所以它被css left: -10000px
移到了屏幕外。
1条答案
按热度按时间dzjeubhm1#
I believe
aria-labelledby
is not used according to the standards, which might explain undefined behaviour.The Accessible Name and Description, step C mentions the following:
If the embedded control has role textbox, return its value.
That means that if an
<input>
, which has implicit roletextbox
, is used as part of an accessible name, not its label, but its value is used as the name.Further, the ARIA standard on
aria-labelledby
reads:If the interface is such that it is not possible to have a visible label on the screen, authors SHOULD use
aria-label
[…]The main purpose of
aria-labelleby
is to refer to part of the visible contents of an element like a<form>
to label it. Most commonly, this would be a heading like<h2>
.The use case of this question is currently unclear to me. The example provided does not make sense with a single
radio
input.<input>
is completely hidden, visually and from assistive technology, why is it there in the first place?<input type="hidden">
would be the more correct input to use if the form data is needed