gpt4 book ai didi

html - 从按钮组中仅选择一个按钮

转载 作者:太空狗 更新时间:2023-10-29 13:57:19 24 4
gpt4 key购买 nike

我想创建一个按钮组,可以一次从组中选择按钮。

假设我们有三个按钮,用户应该只能选择一个按钮,所以如果用户选择“Apple”,那么他们不应该再次选择 Apple 按钮。

主要目的是阻止用户选择已经选择的按钮。

<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
<button type="button" class="btn btn-primary">Sony</button>
</div>

我该如何解决这个问题?

最佳答案

这似乎正是您要搜索的内容。

<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="radio" name="options" id="option1" checked> Apple
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option2"> Samsung
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option3"> Sony
</label>
</div>

您可以阅读更多相关信息 under this link .这是它的样子:

enter image description here

关于html - 从按钮组中仅选择一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31914071/

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