jquery checkbox checked event code example
Example 1: jQuery checkbox changed event
$("#myCheckBoxID").change(function() {
if(this.checked) {
}else{
}
});
Example 2: How to check whether a checkbox is checked in jQuery?
if(document.getElementById('on_or_off_checkbox').checked) {
}
if($('#on_or_off_checkbox').is(':checked')){
}
Example 3: jquery if checkbox checked
$( "SELECTOR" ).attr( "checked" )
$( "SELECTOR" ).prop( "checked" )
$( "SELECTOR" ).is( ":checked" )
Example 4: events on checkbox in jquery
$(document).ready(function() {
$('#textbox1').val($(this).is(':checked'));
$('#checkbox1').change(function() {
if($(this).is(":checked")) {
var returnVal = confirm("Are you sure?");
$(this).attr("checked", returnVal);
}
$('#textbox1').val($(this).is(':checked'));
});
});
Example 5: checkbox is checked jquery
$(your_checkbox).is(':checked');
Example 6: jquery checkbox checked
$("checkbox").is(":checked")