With the following HTML checkbox code
<input type="checkbox" class="example" checked />2016
<input type="checkbox" class="example" />2015
<input type="checkbox" class="example" />2014
<input type="checkbox" class="example" />2013
<input type="checkbox" class="example" />2012
<input type="checkbox" class="example" />2011
<input type="checkbox" class="example" />2010
What changes do I need to make to the following jQuery
$(function() {
$('input[type="checkbox"]').bind('click',function() {
$('input[type="checkbox"]').not(this).prop("checked", false);
});
});
so that one of the checkboxes is checked at all times not allowing blank checkboxes?
Aucun commentaire:
Enregistrer un commentaire