JQuery: How to Validate Checkbox whether the Checkbox is Checked or Unchecked

satinder singh / Updated : / 3 Comments

 jquery checkbox is checked or unchecked: This article explains how to get the checkbox checked status, or validate whether the checkbox is checked or unchecked in jQuery. In other words, how to test the state of checkbox i.e. whether the checkbox is checked or unchecked in jQuery.  Here we use jquery .is() method and matched checked attribute.

Description: The method .is() Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.


Here we have a checkbox control and a button tag, so our HTML look like as shown below:

<input type='checkbox' id='chkFollow'>Follow Me
<button id="btnCheckStatus">Click me</button>


jQuery:  Using .is(“:checked”)  method will return boolean value

So now below written jQuery code, will display checkbox status .i.e whether the checkbox is checked or unchecked on button click.

var chkItem=$("#chkFollow");
        console.log("Yes you are following ");
    else{console.log("No you are not following");}

In above code 1st, we stored the checkbox control in a variable, which we use when button click function trigger, basically assigning variable to control (selector)is good practice for performance wise, i.e. caching the control.

Next we use .is(“:checked”) this return Boolean value. As a result, we got to know our checkbox current status,  checked or unchecked.

Try It Yourself ⇒


3 comments on “JQuery: How to Validate Checkbox whether the Checkbox is Checked or Unchecked”

Post Comment

Your email address will not be published. Required fields are marked *