Home  »  CodeGuidesProgrammingSnippetsTechnology   »   How to Uncheck a Checkbox in jQuery

How to Uncheck a Checkbox in jQuery

Posted: October 3, 2022 | by Site Host

Use this to how to uncheck a checkbox in jQuery:

//jQuery 1.6+ use

$('.checkbox').prop('checked', true);  //false for uncheck

//jQuery 1.5.x and below use

$('.checkbox').attr('checked', true);  //false for uncheck

$('#theCheckbox').prop('checked', true); // Checks it
$('#theCheckbox').prop('checked', false); // Unchecks it

Alternate:

if ($("#checkBoxId").is(':checked')) {
   alert("checked");
} else {
   alert("unchecked");
}

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.