Q:

checkbox click event jquery

$(document).ready(function() {
    //set initial state.
    $('#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'));        
    });
});
3
$(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?");
    }
  });
});
0
$('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());
  }
});
0

New to Communities?

Join the community