Skip to main content

How to Set Checkbox Checked in jQuery

HTML checkboxes are used to allow the user to select one or more items from a list. To create a checkbox, use the <input> element with the type attribute set to “checkbox”. To specify that a checkbox is checked by default, set the checked attribute to “true”.

If you have a checkbox in your HTML form, you can use jQuery to read and set the value of the checkbox based on the change of another element. In this snippet, we will show you how to check and uncheck a checkbox with jQuery.

//To check the checkbox 
$("#aCheckbox").prop("checked", true); 
$("#aCheckbox").attr("checked", "checked"); 

//To uncheck the checkbox
$("#aCheckbox").prop("checked", false); 
$("#aCheckbox").removeAttr("checked"); 

By continuing to use the site, you agree to the use of cookies.