gpt4 book ai didi

html - 使用属性 'for' 链接自定义元素

转载 作者:行者123 更新时间:2023-11-28 04:47:55 25 4
gpt4 key购买 nike

我创建了一个 jQuery 插件,可以像这样转换 HTML 表单

<form>
<input type="checkbox" id="checkbox_01" value="1"/>
<label for="chexkbox_01"></label>
</form>

变成这样的形式:

<form>
<input type="checkbox" id="checkbox_01" value="1" aria-hidden="true" />
<span role="checkbox" id="aria-checkbox_01" aria-checked="false" tabindex="0"></span>
<label for="aria-chexkbox_01"></label>
<form>

更改 for 属性以链接自定义元素是否有效?

最佳答案

没有。

If the attribute is specified, the attribute's value must be the ID of a labelable element in the same Document as the label element.

https://www.w3.org/TR/html5/forms.html#attr-label-for

Some elements, not all of them form-associated, are categorized as labelable elements. These are elements that can be associated with a label element.

button input (if the type attribute is not in the hidden state) keygen meter output progress select textarea

https://www.w3.org/TR/html5/forms.html#category-label

跨度不是可标记元素。

关于html - 使用属性 'for' 链接自定义元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40082489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com