我有3個按鈕/複選框,如果我點擊任何它被檢查,我如何使所有其他按鈕取消選中,如果我點擊當前的。Bootstrap取消選中複選框和樣式
https://jsfiddle.net/DTcHh/31573/
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default btn-lg no-border">
<span id="btnPencil" class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
<input type="checkbox" autocomplete="off">
</label>
<label class="btn btn-default btn-lg no-border">
<span class="glyphicon glyphicon-th-large" aria-hidden="true"></span>
<input type="checkbox" autocomplete="off">
</label>
<label class="btn btn-default btn-lg no-border">
<span class="glyphicon glyphicon-th-large" aria-hidden="true"></span>
<input type="checkbox" autocomplete="off">
</label>
</div>
btnp = document.getElementById(btnPencil)
btnp.addEventListener('change', function() {
// 1. check current button/checkbox
// 2. uncheck other buttons/checkbox
// bootstrap uncheck/check style ?
});
爲什麼不使用'無線電buttons'呢? – Swellar
可能重複的[設置「檢查」的複選框與jQuery?](http://stackoverflow.com/questions/426258/setting-checked-for-a-checkbox-with-jquery) – Micheasl