I have some checkboxes which when you click disable all other checkboxes until you untick the checked box. This is working great. But i also want to incorporate a toggleClass 'active' on the labels.
So when you click a label it adds class active. But if you click another label it doesn't add class active until you un-toggle the class off the previously clicked label. Sorry if that sounds a little confusing.
I have the js working for the checkboxes part here:
$('.test').change(function(){
if($('input.test').filter(':checked').length == 1)
$('input.test:not(:checked)').attr('disabled', 'disabled');
else
$('input.test').removeAttr('disabled');
});
and i have the toggleClass for the label
$('.holder label').click(function() {
$('.holder label').not(this).removeClass('active')
$(this).toggleClass('active')
})
But they somehow need to work together. You'll get a better idea by checking out this fiddle http://ift.tt/2xkIivH
e.g. if you clicked 'Label1' its correct (text goes bold and checkbox is ticked). But if you click 'Label2' that should add 'active' class (and go bold) until you uncheck 'Label1'
Thanks
Aucun commentaire:
Enregistrer un commentaire