c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
JQuery

How to check checkbox is checked and unchecked in jquery ?

| | check-box , JQuery

The jQuery prop() method is used to know the status of checkboxes which specifies its checked or unchecked status.



Do not confuse with "checked" attribute. The "checked" attribute only define the initial state of the checkbox, and not the current state.



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