How do I check whether a checkbox is checked in jQuery?
Loading
How do I check whether a checkbox is checked in jQuery?
The jQuery prop() method provides a simple, effective, and reliable way to track down the current status of a checkbox. It works pretty well in all conditions because every checkbox has a checked property which specifies its checked or unchecked status.
Lets see how it work.
$(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.”);
}
});
});