Bootstrap btn-group不会更改单选按钮 [英] Bootstrap btn-group doesn't change radio buttons

查看:99
本文介绍了Bootstrap btn-group不会更改单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这里是我的标记

So here is my markup

      <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,它不会标记第三个单选按钮被选中,或者我选择了其他选项,所以当我提交表单时,我选择哪个选项并不重要,默认选中的选项将被提交。

It renders everything fine, the problem is that if I select value 3, it won't mark the third radio buttons as checked, or any other options if I select it, so when I submit the form, it doesn't matter which option I choose, the option that is checked by default, that will be submitted.

任何提示?

Any tips?

推荐答案

可能是因为你有这两个相同的id单选按钮

It could be because you have the same id for these two radio buttons

  <input type="radio" name="account-type" id="optionsRadios2" value="2" checked>

  <input type="radio" name="account-type" id="optionsRadios2" value="3">

将最后一个更改为 id =optionsRadios3

这篇关于Bootstrap btn-group不会更改单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆