jsquery click checkbox code example

Example 1: checkbox on click jquery

$(document).ready(function() {
  //set initial state.
  $('#textbox1').val($(this).is(':checked'));

  $('#checkbox1').change(function() {
    $('#textbox1').val($(this).is(':checked'));
  });

  $('#checkbox1').click(function() {
    if (!$(this).is(':checked')) {
      return confirm("Are you sure?");
    }
  });
});

Example 2: checkbox click event jquery

$('input[type="checkbox"]').click(function(){
  if($(this).is(":checked")){
    //input element where you put value
    $("#isClicked").val("Yes");
    // console.log($("#isClicked").val());              
  }
  else if($(this).is(":not(:checked)")){
    $("#isClicked").val("");
    //  console.log( $("#isClicked").val());
  }
});