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
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
}
xxxxxxxxxx
// HTML
<input type="checkbox" id="myCheckbox">
// jQuery
if ($('#myCheckbox').is(':checked')) {
console.log('Checkbox is checked');
} else {
console.log('Checkbox is not checked');
}