[英]aria-describedby - Same description for two fields?
Assuming the code below:假设下面的代码:
<label for="carType">Choose a car:</label>
<select name="carType" id="cars" aria-describedby="feedback">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<label for="carPrice">Enter a purchase price:</label>
<input id="carPrice" type="number" aria-describedby="feedback"></input>
<div id="feedback">The {car} you are considering for {carPrice} is {good/bad} value.</div>
I have used the aria-describedby attribute relating to the feedback div twice.我已经两次使用了与反馈div 相关的aria-describedby属性。 Is this acceptable use?这是可以接受的用途吗? I haven't found any documentation that says this isn't allowed, however it seems there might be another solution.我还没有找到任何文件说这是不允许的,但似乎可能有另一种解决方案。
Kind regards亲切的问候
There is nothing wrong with several elements pointing to the same aria-describedby
element.多个元素指向同一个aria-describedby
元素并没有错。 Both "carType/cars" and "carPrice" can point to "feedback". “carType/cars”和“carPrice”都可以指向“反馈”。
Note that your first <select>
will not have a label because the <label for="carType">
is using the wrong ID in the for
attribute.请注意,您的第一个<select>
将没有标签,因为<label for="carType">
在for
属性中使用了错误的 ID。 Your <select>
has a name attribute of "carType" but name is used for javascript access.您的<select>
具有“carType”的名称属性,但名称用于 javascript 访问。 The for
attribute should refer to the value of the ID
attribute. for
属性应该是指ID
属性的值。 So you need to change your <label>
to <label for="cars">
所以你需要把你的<label>
改成<label for="cars">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.