I have a dropdown list with different categories which i've setup like this:
Main1
sub1
sub1
sub1
Main2
sub2
sub2
sub2
etc.
When I press on "Main1" all "Sub1"s will be checked, and so on. I have made a function that works.
$('.main_check_1').change(function() {
var checkboxes = $(".check_1");
if($(this).is(':checked')) {
checkboxes.prop('checked', true);
} else {
checkboxes.prop('checked', false);
}
});
but only if I hard code it, it doesn't work dynamically.
(On my admin page i'll be capable of adding more and give them an id, Main"1", Sub"1" etc).
Any idea how I could do this?
HTML?