xxxxxxxxxx
if($("#rule").is(":checked")){
$("#form").submit();
}
xxxxxxxxxx
//using plane javascript
if(document.getElementById('on_or_off_checkbox').checked) {
//I am checked
}
//using jQuery
if($('#on_or_off_checkbox').is(':checked')){
//I am checked
}
xxxxxxxxxx
$( "SELECTOR" ).attr( "checked" ) // Returns ‘true’ if present on the element, returns undefined if not present
$( "SELECTOR" ).prop( "checked" ) // Returns true if checked, false if unchecked.
$( "SELECTOR" ).is( ":checked" ) // Returns true if checked, false if unchecked.
xxxxxxxxxx
if ($('#grepperRocks').is(':checked')) {
// this checkbox is checked
}
xxxxxxxxxx
$('.myCheckbox').prop('checked', true);
$('.myCheckbox').prop('checked', false);
xxxxxxxxxx
//using plane javascript
if(document.getElementById('on_or_off_checkbox').checked) {
//I am checked
}
//using jQuery
if($('#on_or_off_checkbox').is(':checked')){
//I am checked
}
xxxxxxxxxx
var isChecked = $('#checkboxId').prop('checked');
if(isChecked == true){
//code
}