Bootstrap data-toggle =“ buttons”单选属性

Bur*_*kan 5 onchange radio-button twitter-bootstrap

我看到Bootstrap单选按钮(使用data-toggle =“ buttons”创建)更改事件在标签之间切换了活动类,并且对实际单选按钮的选中属性没有影响。这是正常行为还是我有误?

或者,如何才能双向绑定此活动的标签类和收音机的选中属性,以使它们同时更改?

示例代码:

<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>
Run Code Online (Sandbox Code Playgroud)

小智 0

检查这个代码

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary active">
    <input type="radio" name="options1" id="option1" autocomplete="off"> Radio 1 (preselected)
  </label>
  <label class="btn btn-primary">
    <input type="radio" name="options2" id="option2" autocomplete="off"> Radio 2
  </label>
  <label class="btn btn-primary">
    <input type="radio" name="options3" id="option3" autocomplete="off"> Radio 3
  </label>
</div>
Run Code Online (Sandbox Code Playgroud)

问候