I am attempting to do two things:
- Ensure a checkbox is not checked on page load by unchecking it
- If a checkbox is checked and the mouse is clicked anywhere else on the screen, it will be unchecked.
For the first part, I have tried:
$(document).ready(function() {
$('#cbox').removeAttr('checked');
});
However, this will not allow me to check it manually once the page is loaded.
For the second part, I tried:
$(document).click(function() {
if ($('#cbox').is(':checked')) {
$('#cbox').removeAttr('checked');
}
});
But the problem with this is that if you click the actual checkbox to check it, the check is fired before this is, so the checkbox is always not checked.
How can I correct this?