屏幕阅读器忽略了禁用的属性

问题描述 投票:0回答:1

我有一个步进器-物料用户界面编号字段。它已禁用,但屏幕阅读器可以更改数字(递增和递减)。 HTML如下:

<input aria-invalid="false" id="outlined-number" type="number" class="MuiInputBase-input MuiOutlinedInput-input" disabled="true" value="3">
javascript input material-ui screen-readers disabled-input
1个回答
3
投票

disabled属性指定错误。从https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes

2.4.2布尔属性

许多属性是布尔属性。元素上存在布尔属性表示真实值,而缺少属性则表示假值。

如果存在该属性,则其值必须为空字符串或该属性的规范名称的ASCII大小写不匹配的值,并且没有前导或尾随空格。

布尔属性上不允许使用值“ true”和“ false”。为了表示一个假值,必须完全省略该属性。

将代码更改为disabled="disabled"

© www.soinside.com 2019 - 2024. All rights reserved.