我在使用Bootstrap插件时遇到了问题,以下是我的一些单选按钮的代码:
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Radio 1 (preselected)
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option2" autocomplete="off"> Radio 2
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option3" autocomplete="off"> Radio 3
</label>
</div>
我想要添加一个重置选择的按钮。我尝试过使用重置按钮(
<button type="reset">
)、jQuery命令,但都失败了。在Bootstrap API中,我找到了一个解释:http://getbootstrap.com/javascript/#buttons-checkbox-radio 其中写道:
请问是否有人能帮我找到解决方案?只有在点击时才更新可视选中状态。如果复选框按钮的选中状态在不触发按钮的单击事件的情况下进行更新(例如通过<input>或通过设置输入的checked属性),则需要自己在输入的标签上切换 .active 类
谢谢,Gabriel。