【问题标题】:Multiple button groups - selection issue多个按钮组 - 选择问题
【发布时间】:2016-08-25 14:06:19
【问题描述】:

我有 2 个动态创建的引导按钮组。当我选择一个按钮时,它会起作用。但是,只要我在 OTHER 组中选择另一个按钮,它就会取消选择原来的按钮。所以基本上我只能选择一个按钮,即使它们位于不同的按钮组中。知道为什么吗?按钮组 ID 是唯一的。

<div class="container">
  <h2>Button Group</h2>
  <div class="btn-group" id="group1">
    <button type="button" class="btn btn-primary">Apple</button>
    <button type="button" class="btn btn-primary">Samsung</button>
    <button type="button" class="btn btn-primary">Sony</button>
  </div>
  <div class="btn-group" id="group2">
    <button type="button" class="btn btn-primary">Apple</button>
    <button type="button" class="btn btn-primary">Samsung</button>
    <button type="button" class="btn btn-primary">Sony</button>
   </div>
</div>

【问题讨论】:

    标签: css twitter-bootstrap twitter-bootstrap-3


    【解决方案1】:

    这将解决您的问题。

    <div class="container">
      <h2>Button Group</h2>
      <div class="btn-group" data-toggle="buttons">
        <label for="" class="btn btn-primary">
            <input type="radio" >Apple
        </label>
        <label for="" class="btn btn-primary">
            <input type="radio" >Samsung
        </label>
        <label for="" class="btn btn-primary">
            <input type="radio">Sony
        </label>
      </div>
    
      <div class="btn-group" data-toggle="buttons">
         <label for="" class="btn btn-primary">
            <input type="radio" >Apple
         </label>
         <label for="" class="btn btn-primary">
            <input type="radio" >Samsung
         </label>
         <label for="" class="btn btn-primary">
            <input type="radio" >Sony
         </label>
       </div>
    </div>
    

    【讨论】:

    • 这对我不起作用。按钮组一直相互关联,我只能从所有组中选择一个按钮。
    • @Rawburner 开始一个新问题。您的问题可能会有所不同。
    • 我发现了问题。我有一个标签而不是标签和输入。和他们一起没用。对不起。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-16
    • 2015-12-25
    • 2020-02-24
    • 2017-09-07
    • 2017-09-05
    • 2011-03-12
    相关资源
    最近更新 更多