这是我的标记
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="account-type" id="optionsRadios1" value="1"> <span class="glyphicon glyphicon-user"></span>
User</label>
<label class="btn btn-primary active">
<input type="radio" name="account-type" id="optionsRadios2" value="2" checked> <span class="glyphicon glyphicon-eye-open"></span>
Special user</label>
<label class="btn btn-primary">
<input type="radio" name="account-type" id="optionsRadios2" value="3"> <span class="glyphicon glyphicon-home"></span>
Agency</label>
</div>
它呈现一切正常,问题是如果我选择值 3,它不会将第三个单选按钮标记为已选中,或者如果我选择它则不会标记任何其他选项,所以当我提交表单时,它不会无论我选择哪个选项,默认选中的选项都会被提交。
有什么建议吗?
最佳答案
正如有人指出的,您的第三个单选按钮 ID 是错误的。
但这不是问题:
真正的问题是您在 Bootstrap 后加载 jQueryUi(我猜)。这是一个已知的“错误”。只需在 Bootstrap 之前加载 jQueryUi,一切都会正常运行
关于html - Bootstrap btn-group 不会更改单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22206303/