checkbox check using jquery code example

Example 1: Setting “checked” for a checkbox with jQuery

$('.myCheckbox').prop('checked', true);
$('.myCheckbox').prop('checked', false);

Example 2: How to check whether a checkbox is checked in jQuery?

//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
}

Example 3: checkbox is checked jquery

$("#out_of_stock_toggle").click(function(){
      if($(this).is(':checked')){
        //show oos
        $(".oos").fadeIn();
      }else{
        //hide oos
        $(".oos").fadeOut();
      }
    });

Example 4: jquery get checkbox condition

if ($('input.checkbox_check').is(':checked')) {

Example 5: checkbox jquery checked

var isExpanded = $(this).attr('checked') == "checked";