![](/img/trans.png)
[英]checkbox onChange in <legend> inside disabled <fieldset> not firing in Firefox with React
[英]Semantic Validity of a Checkbox in a Fieldset Legend?
如果我有一个复选框可以切换一组复选框的激活/停用,那么将其放在字段集的图例中在语义上是否有效?
<fieldset>
<legend><label><input type="checkbox"/>Sports</label></legend>
<label><input type="checkbox"/>Baseball</label>
<label><input type="checkbox"/>Football</label>
<label><input type="checkbox"/>Ulama</label>
</fieldset>
这是HTML要做的“精髓”,但我无法给出令人满意的答案:
是的,这是唯一的方法。
您可以使用Javascript将复选框的change事件与具有字段集的Disabled属性连接起来。
像这样:
$('fieldset > legend checkbox').on('change', function(event) {
$(this).closest('fieldset').prop('disabled', !$(this).prop('checked'));
});
在这种情况下,可以禁用该字段集,但仍可以通过图例中的复选框启用该字段集,因为未禁用该字段集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.