I have a bit of a problem with some html im writing and was wondering if someone could help.
I have 6 checkboxes which are the following
Monday
Tuesday
Wednesday
Thursday
Friday
All Days
HTML is as follows:
<input type="checkbox" name="monday" value="1" id="monday" />
<input type="checkbox" name="tuesday" value="1" id="tuesday" />
<input type="checkbox" name="wednesday" value="1" id="wednesday" />
<input type="checkbox" name="thursday" value="1" id="thursday" />
<input type="checkbox" name="friday" value="1" id="friday" />
<input type="checkbox" name="alldays" value="1" id="alldays" />
I already have some jquery which when “All Days” is selected, checks all the rest of the checkboxes.
The jQuery i have at the moment is as follows:
<script>
$(function(){
$("#alldays").change(function(){
if (this.checked) {
$("input:checkbox.child").attr("checked", "checked");
}
else {
$("input:checkbox.child").removeAttr("checked");
}
});
});
</script>
I want to add another bit of jQuery, if all six of the checkboxes are ticked, and someone clicks off one of the weekdays, the “All Days” checkbox will automatically uncheck.
Could someone help me out with this please.
Cheers
Try this: