Skip to main content

There are a number of different ways to check if a checkbox is checked (ticked). You can use either jQuery or plain JavaScript it doesn't really matter. Here are 3 examples to wet your appetite. Could be useful when you need to check that a user has ticked a checkbox before submitting a form.

// First way
$('#checkBox').attr('checked');

// Second way
$('#edit-checkbox-id').is(':checked');

// Third way for jQuery 1.2
$("input[@type=checkbox][@checked]").each(function() {
  // Insert code here
});

// Third way == UPDATE jQuery 1.3
$("input[type=checkbox][checked]").each(function() {
  // Insert code here
});