codingtcher.com
Theme Night
Home
Login

Uncheck checkbox jquery

Jquery Example


$("#myCheck").click(function(){
  if (this.checked){
    $('#text').show();
  } else {
     $('#text').hide();
  }
});

Jquery Example 2


$("#myCheck2").click(function(){
  if (this.checked){
    $('#text2').html("Checkbox is CHECKED!");
  } else {
     $('#text2').html("Checkbox is UNCHECKED!");
  }
});

Javascript Example


function myFunction() {
  var checkBox = document.getElementById("myCheck");
  var text = document.getElementById("text");
  if (checkBox.checked == true){
    text.style.display = "block";
  } else {
     text.style.display = "none";
  }
}

Javascript Example 2


function myFunction2() {
  var checkBox = document.getElementById("myCheck2");
  var text = document.getElementById("text2");
  if (checkBox.checked == true){
    text.innerHTML = "Checkbox is CHECKED!";
  } else {
     text.innerHTML = "Checkbox is UNCHECKED!";
  }
}
//how to uncheck a checkbox in jquery
$("#myCheckBox").prop("checked", false);

//jquery set checkbox checked unchecked
$('#myCheckbox').prop('checked', true); // Checks it
$('#myCheckbox').prop('checked', false); // Unchecks it

//get unchecked checkbox jquery
if ($("#check_box_id").is(':checked')) {
  alert("checked");
}else{
  alert("unchecked");
}

//jquery checkbox unchecked
$("input:radio[name='NAME']:radio[value='VALUE']").attr("checked",true);
$("input:radio[name='NAME']").removeAttr("checked");

Related Code