引导3
我正在努力使每组按钮组独一无二,但不同的组是相互干扰的
<label>Payment Mode</label> <div class="btn-group"> <button type="button" class="btn btn-default">Cash / Cheque / Bank Transfer </button> <button type="button" class="btn btn-default">JobsBuddy Disbursement</button> </div> <label>Payment Period</label> <div class="btn-group"> <button type="button" class="btn btn-default">Immediate</button> <button type="button" class="btn btn-default"> More Than 1 day</button> </div>
我如何保持独特的自己的组
解决方法
您可能想使用提供的Bootstrap单选按钮组(
http://getbootstrap.com/javascript/#buttons),然后使用reset方法来清除其他组.
HTML:
<label>Payment Mode</label> <div id="mode-group" class="btn-group" data-toggle="buttons"> <label class="btn btn-primary"> <input type="radio" name="mode" id="option1"> Cash / Cheque / Bank Transfer </label> <label class="btn btn-primary"> <input type="radio" name="mode" id="option2"> JobsBuddy Disbursement </label> </div> <label>Payment Period</label> <div id="period-group" class="btn-group" data-toggle="buttons"> <label class="btn btn-primary"> <input type="radio" name="period" id="period1"> Immediate </label> <label class="btn btn-primary"> <input type="radio" name="period" id="period2"> More Than 1 day </label> </div>
jQuery的:
// unselect period when mode is selected $("#mode-group .btn").on('click',function(){ $("#period-group").button('reset'); });