Button 如何使按钮组像单选按钮组一样工作?

Button 如何使按钮组像单选按钮组一样工作?,button,twitter-bootstrap-3,radio-group,buttongroup,Button,Twitter Bootstrap 3,Radio Group,Buttongroup,我使用的是Bootstrap3,我想让两个按钮作为单选按钮工作,但我不知道怎么做。这是我的密码 <div class="btn-group" > <div class="btn-group"> <button type="button" class="btn btn-default"> PERSONAL </button> </div> <div cl

我使用的是Bootstrap3,我想让两个按钮作为单选按钮工作,但我不知道怎么做。这是我的密码

<div class="btn-group" >
    <div class="btn-group">
        <button type="button" class="btn btn-default">
            PERSONAL
        </button>
    </div>
    <div class="btn-group">
        <button type="button" class="btn btn-default">
            COMPANY
        </button>
    </div>
</div>

个人的
公司
当我选择PERSONAL时,另一个将被取消选择(应该如此),但问题是:

  • 当表单启动时,它们都不处于活动状态
  • 我可以取消选择窗体外的两个单击
您可以将其中一个设置为活动,并将“活动”类添加到标签-“btn btn primary active”和“checked”添加到输入收音机

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option1"> Option 1
  </label>
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option2"> Option 2
  </label>
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option3"> Option 3
  </label>
</div>
$('.btn').button()