How to check if checkbox is checked or not in JQuery?

How to check if checkbox is checked or not in JQuery?

In this post we will give you information about How to check if checkbox is checked or not in JQuery?. Hear we will give you detail about How to check if checkbox is checked or not in JQuery?And how to use it also give you demo for it if it is necessary.

Hi Dev,

Here, i will show you how to works jquery check if checkbox is checked or not. you can see how to check checkbox is checked or not in jquery on button click. Here you will learn jquery get checkbox value if checked.

if you have question about how to check checkbox is checked or not in jquery using id then i will give simple example with solution. You just need to some step to done jquery check if checkbox is checked or not.

We will use jquery prop() method to check checkbox is checked or not. So you can see bellow simple full example that will help you to understand example.

Solution:

$('input[type="checkbox"]').click(function(){

if($(this).prop("checked") == true){

alert("you checked checkbox.");

}else if($(this).prop("checked") == false){

alert("you unchecked checkbox.");

}

});

Example:

<!DOCTYPE html>

<html>

<head>

<title>jquery check if checkbox is checked or not - onlinecode</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

</head>

<body>

<h1>jquery check if checkbox is checked or not - onlinecode</h1>

<label>

<input type="checkbox" name="i_agree"> I agree

</label>

<script>

$(document).ready(function(){

$('input[type="checkbox"]').click(function(){

if($(this).prop("checked") == true){

alert("you checked checkbox.");

}else if($(this).prop("checked") == false){

alert("you unchecked checkbox.");

}

});

});

</script>

</body>

</html>

I hope it can help you…

Hope this code and post will helped you for implement How to check if checkbox is checked or not in 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 code 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 *

8  +  2  =  

We accept paid advance and paid guest Posting on our Site : Contact US