gpt4 book ai didi

html - Bootstrap 按钮单选组默认值(检查属性)不起作用

转载 作者:技术小花猫 更新时间:2023-10-29 12:04:48 25 4
gpt4 key购买 nike

经过无数小时的研究,我仍然对如何为 Bootstrap 的按钮单选组使用 checked 属性感到困惑。我正在尝试默认“优秀”。

尽管我确定 radio 输入是checked而不是selected,但我什至尝试了selected但没有任何效果。

<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="inputWalls" id="inputWalls" value="Excellent" checked>
Excellent </label>
<label class="btn btn-default">
<input type="radio" name="inputWalls" id="inputWalls" value="Good">
Good </label>
<label class="btn btn-default">
<input type="radio" name="inputWalls" id="inputWalls" value="Poor">
Poor </label>
</div>

如果需要澄清,请告诉我。

最佳答案

在 twitter bootstrap 中,您将使用“active”类指示默认值。因此,对于您的示例,如果您使用的是 Twitter Bootstrap,则以下代码将使用 Excellent 作为默认选中项。

<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default **active**">
<input type="radio" name="inputWalls" id="inputWalls" value="Excellent" checked>
Excellent </label>
<label class="btn btn-default">
<input type="radio" name="inputWalls" id="inputWalls" value="Good">
Good </label>
<label class="btn btn-default">
<input type="radio" name="inputWalls" id="inputWalls" value="Poor">
Poor </label>
</div>

当您切换按钮时,您会添加/删除类 - 来自标签类的“事件”。

例如,查看此 - http://getbootstrap.com/javascript/#buttons - radio

关于html - Bootstrap 按钮单选组默认值(检查属性)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18326230/

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