asked on
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>
$(document).ready(function () {
$('.compbox :checkbox').not(".hidebox").click(function () {
var exclude = "";
$('.compbox :checkbox').not($(this).add(exclude)).removeAttr('checked');
});
});
</script>
<style>
.hidebox {display:none;}
.compbox {display:inline-block;}
</style>
<div class="compbox">
<input type="checkbox" class="hidebox" />
<input type="checkbox" class="compbox" /> AAA
<input type="checkbox" class="compbox" /> BBB
<input type="checkbox" class="compbox" /> CCC
<input type="checkbox" class="compbox" /> DDD
<input type="checkbox" class="compbox" /> EEE
<input type="checkbox" class="compbox" /> FFF
</div>
Ideally I would like this to not be reliant upon the first checkbox and work without the need for an extra hidden one.