HTML:
<form class="form">
<input type="checkbox" id="box" /> Check Me!
</form>
JS:
$(window).load(function() {
var myFunc = function() {
if($('#box').prop('checked', false)) {
$('.form').append('<p>Checkbox is not checked.</p>');
}
}
$('#box').on('change', myFunc);
});
Here is a JSFiddle http://jsfiddle.net/3PYm7/
When I use $('#box').prop('checked', false)
as a condition for the if
statement it does not work, but ! $('#box').prop('checked')
works just fine!