I have an array of checkboxes which can be used in a sort of calendar app. Whenever the checkbox gets checked, a label should become visible. My HTML looks something like this:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
CheckVisibility();
})
function CheckVisibility(){
if($('#cb').is(':checked')){
$('#label').show()
}
else{
$('#label').hide()
}
}
</script>
<table>
<tr>
<td><input type=checkbox id="cb" onchange="CheckVisibility()"/></td>
<td><label id="label" style="display : none">Monday</label></td>
<tr>
</table>
And it works fine on first load. However, when I return to the previous page, the checkbox is still checked. This is the behaviour I want, but it won't get registered as "checked" when passing $(document).ready fires of CheckVisibility(). Any idea's?