gpt4 book ai didi

checkbox - 轨道 check_box_tag + label_tag

转载 作者:行者123 更新时间:2023-12-05 06:46:00 25 4
gpt4 key购买 nike

在我看来,我有一个复选框和一个标签。我正在使用 SLIM,所以代码是

= check_box_tag 'All Products'
= label_tag 'All Products'

生成的等效 HTML 是

<input id="All_Products" name="All Products" type="checkbox" value="1">
<label for="All_Products">All products</label>

即使“input id”和“label for”都具有相同的值,即“All_Products”,但我无法在单击标签时选中该复选框。

有什么我遗漏的吗?

我想在点击标签时选中复选框。

最佳答案

`All Products' 可能不是用于元素 id/name 的最佳名称(即使它确实被转换),也许可以尝试一些更简洁的名称,例如

= check_box_tag 'all-products'
= label_tag 'all-products', 'All Products'

应该产生

<input id="all-products" name="all-products" type="checkbox" value="1" />
<label for="all-products">All Products</label>

关于checkbox - 轨道 check_box_tag + label_tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19744130/

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