How to make a checkbox checked with jQuery? [duplicate]

$('#test').prop('checked', true);

Note only in jQuery 1.6+


$('#test').attr('checked','checked');

$('#test').removeAttr('checked');

$('#checkbox').prop('checked', true);

When you want it unchecked:

$('#checkbox').prop('checked', false);

I think you should use prop(), if you are using jQuery 1.6 onwards.

To check it you should do:

$('#test').prop('checked', true);

to uncheck it:

$('#test').prop('checked', false);