I have this Jquery:
$(document).ready(function() {
$('#masterChecks input[type="checkbox"]').click(function() {
var togClass=$(this).attr('class');
if($(this).attr('checked')){
//need to make sure all checkboxes for this class is checked, when the
//master checkbox is checked.
$('div.' + togClass ).css("display", "inline-block");
}
else
{
//need to make sure all checkboxes for this class is unchecked, when the
//master checkbox is checked.
$('div.' + togClass ).css("display", "none");
}
});
});
I have Html with many divs, and many classes. There are many checkboxs. Now i am checking the mastercheckbox, which will hide the css of all attributes that have the same class as the checkbox. I also have a set of local checkboxes which do the same but only for the div they are in. I want the Jquery uncheck the local checbox with the same class when it is unchecked, and vice versa. here is the html struccture
<div id="masterChecks">
// checbox here with class="sampleclass"
</div>
<div class="sampleclass">
//local checkbox here
</div>
it seems very straight forward , but cant get it to work,
ive tried some things like this:
$('div.' + togClass + 'input[type="checkbox"]').attr('checked','checked');
can anyone help?