jQuery: How to check and uncheck a Checkbox CodeUnit 10 FEB 2010

Checking and unchecking, or ticking and unticking if you prefer, checkboxes using jQuery is remarkably simple.

If you think about it, the checked attribute for a standard HTML checkbox is actually a deprecated “checked = true” and by leaving it out in your checkbox declaration, you are in actual fact setting “checked = false” on that input.

So in order to check a checkbox with jQuery you simple select the checkbox input to be affected and enter:

$('input[name=foo]').attr('checked', true);

Alternatively, to uncheck you actually physicall remove the checked attribute:


Pretty simple stuff eh? ;)

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.