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. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close