How to set “checked” for a checkbox with jQuery?

You can use the checked attribute to enable the checkbox for jQuery. You can also use prop() to get the property’s value.


The following code can be used to show you how to set checked to a checkbox.

<!DOCTYPE html>
  <title>jQuery Example</title>
  b {
     color: green;
  <script src=""></script>
<input id="checkbox1" type="checkbox" checked="checked">
<label for="checkbox1">Check/ Uncheck this checkbox</label>
$( "input" ).change(function() {
  var $input = $( this );
  $( "p" ).html(
    ".attr( \"checked\" ): <b>" + $input.attr( "checked" ) + "</b><br>" +
    ".prop( \"checked\" ): <b>" + $input.prop( "checked" ) + "</b><br>" +
    ".is( \":checked\" ): <b>" + $ ":checked" ) + "</b>" );