多个按钮组-选择问题 [英] Multiple button groups - selection issue
本文介绍了多个按钮组-选择问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个动态创建的自举按钮组.当我选择一个按钮时,它可以工作.但是,一旦我选择了另一个按钮,则在其他"组中,它将取消选择原始按钮.因此,基本上,即使它们处于不同的按钮组中,我也只能选择一个按钮.知道为什么吗?按钮组ID是唯一的.
I have 2 DYNAMICALLY created bootstrap button groups. When I select a button it works. But, as soon as I select another button, in the OTHER group, it de-selects the original one. So basically I can only have ONE button selected, even though they are in different button groups. Any idea why? The button groups ids are unique.
<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>
推荐答案
这将解决您的问题.
<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>
这篇关于多个按钮组-选择问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文