check a checkbox is checked or not using jQuery

check a checkbox is checked or not using jQuery

In this post we will give you information about check a checkbox is checked or not using jQuery. Hear we will give you detail about check a checkbox is checked or not using jQueryAnd how to use it also give you demo for it if it is necessary.

Use the jQuery prop() method & :checked selector

The following section describes how to track the status of checkboxes whether it is checked or not using the jQuery prop() method as well as the :checked selector.


<script>
    $(document).ready(function(){
        $('input[type="checkbox"]').click(function(){
            if($(this).prop("checked") == true){
                console.log("Checkbox is checked.");
            }
            else if($(this).prop("checked") == false){
                console.log("Checkbox is unchecked.");
            }
        });
    });
</script>


You can also use the jQuery :checked selector to check the status of checkboxes. The :checked selector specifically designed for radio button and checkboxes.


Let’s take a look at the following example to understand how it basically works:



<script>
    $(document).ready(function(){
        $('input[type="checkbox"]').click(function(){
            if($(this).is(":checked")){
                console.log("Checkbox is checked.");
            }
            else if($(this).is(":not(:checked)")){
                console.log("Checkbox is unchecked.");
            }
        });
    });
</script>


 

Hope this and post will helped you for implement check a checkbox is checked or not using jQuery. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

  +  41  =  46

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US