Ask questions and get good answers on jQuery

How to check and uncheck a checkbox with jQuery and how do I know if a checkbox is checked ?

asked Nov 04 '09 at 11:07

Federico%20Soldani's gravatar image

Federico Soldani
173128

edited Nov 04 '09 at 22:47

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129


to check/uncheck:

// applied to all checkbox of a form:    
 $("#MyFormID input[type='checkbox']").each(function(){
      $(this).attr('checked', $(this).is(':checked')); 
  });

//applied to a specific checkbox of a form:
$("#MyCheckboxID").attr('checked', $("#MyCheckboxID").is(':checked'));

to know if the checkbox is checked:

$("# MyCheckboxID").is(':checked');

answered Nov 04 '09 at 11:33

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129

Your answer
toggle preview

jQuery main site - Matteo Bicocchi