How to Detect User Has Checked or Unchecked a Checkbox in JavaScript

Hello devs, do you know How to detect that a user has unchecked a checkbox or checked a check box by clicking? Sometimes we need to show some data after clicking a checkbox or hiding some data after clicking a checkbox.

In this example i will show you that how to detect check uncheck in checkbox jquery javascript. I will simply show you the source code of detect checkbox checked unchecked with jquery. I will use  jQuery prop() method to check or uncheck a checkbox dynamically.

Example code : 

$("input[type=checkbox]").click(function() {
   if ($(this).prop("checked")) {
      //checked
   }
  else{
    //unchecked
    }
});

 

Read also : How to Make the Window Full Screen with JavaScript

 

Hope it can help you.

 

Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js