I know there is a way to simplify these checkbox onClick functions. I'm just not sure how to make it happen.
Upon checking the checkAllProfiles checkbox, all of the profileCheckboxes are checked:
$('#checkAllProfiles').on('click', function()
{
$(".profileCheckbox").prop('checked', $(this).prop('checked'));
});
Then, if one of the profileCheckboxes are checked, it unchecks the checkAllProfiles checkbox:
$(".profileCheckbox").on('click', function()
{
$(".checkAllProfiles").prop("checked", false );
});
Now here is another set of checkboxes that require the same functionality:
$('#checkAllRegions').on('click', function()
{
$('.regionCheckbox').prop('checked', $(this).prop('checked'));
});
$(".regionCheckbox").on('click', function()
{
$(".checkAllRegions").prop("checked", false );
});
I want to be able to simplify this code. How can I do it?