<label for=FORM_ELEMENT>使用错误求助:for属性未匹配对应元素ID
修复
你的label标签的for属性值billing_country没有对应到任何表单元素的id属性,这会导致浏览器自动填充失效、辅助功能工具无法正常识别关联关系。
修复方法
- 找到和这个label关联的表单字段(比如下拉选框、文本输入框),给该字段添加
id="billing_country"属性,确保和label的for值完全一致(大小写敏感)。 - 页面中每个表单元素的
id必须唯一,不能重复使用。
示例代码
如果关联的是下拉选框:
<label for="billing_country" class="">País / Región <abbr class="required" title="obligatorio">*</abbr></label> <select id="billing_country" name="billing_country"> <option value="">请选择国家/地区</option> <!-- 其他选项 --> </select>
如果关联的是文本输入框:
<label for="billing_country" class="">País / Región <abbr class="required" title="obligatorio">*</abbr></label> <input type="text" id="billing_country" name="billing_country" placeholder="输入国家/地区">
内容的提问来源于stack exchange,提问作者Francisco Andraca
相关产品推荐
相关产品推荐

