How do you check whether a checkbox is currently checked in jQuery?
Use **.is(“:checked”)** or **.prop(“checked”)** on the jQuery selector—both return a clean boolean (trueorfalse`) reflecting the live DOM state of the checkbox.
Check Checkbox State in jQuery
// Method 1: .is(':checked') (Most readable)
if ($("#agreeTerms").is(":checked")) {
console.log("Checkbox is checked!");
}
// Method 2: .prop('checked') (Direct DOM property lookup)
const isChecked = $("#agreeTerms").prop("checked");
Avoid .attr("checked")
.attr("checked") only reads the initial HTML attribute from page load and does not update when the user clicks the checkbox. '
You must log in or register to comment.
