I use this piece of code that was written with jquery 1.4.2 I didn't write it my self obviously and I don't have enough knowledge of jquery to know how to rewrite this for the latest version of jquery so it doesn't break when importing the new jquery library.
$('input[type=checkbox]').change(function(){
name = $(this).attr('class');
id = $(this).attr('id');
checked = $(this).attr('checked');
$('input[type=checkbox][class='+name+']:not(#'+id+')')
.attr('disabled',checked)
.each(function(){
lid = $(this).attr('id');
if (checked) {
$('label[for='+lid+']').addClass('disabled');
} else {
$('label[for='+lid+']').removeClass('disabled');
}
});
});
This is the original post where I got it from, it includes a jsfiddle link :) Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire