Despite the fact that this question is asking for a jQuery solution, here is a pure JavaScript answer since nobody has mentioned it.
Without jQuery:
Simply select the element and access the checked property (which returns a boolean).
var checkbox = document.querySelector('input[type="checkbox"]');
alert(checkbox.checked);
Here is a quick example listening to the change event:
var checkbox = document.querySelector('input[type="checkbox"]');
checkbox.addEventListener('change', function (e) {
alert(this.checked);
});
To select checked elements, use the :checked pseudo class (input[type="checkbox"]:checked).
Here is an example that iterates over checked input elements and returns a mapped array of the checked element's names.
var elements = document.querySelectorAll('input[type="checkbox"]:checked');
var checkedElements = Array.prototype.map.call(elements, function (el, i) {
return el.name;
});
console.log(checkedElements);
var elements = document.querySelectorAll('input[type="checkbox"]:checked');
var checkedElements = Array.prototype.map.call(elements, function (el, i) {
return el.name;
});
console.log(checkedElements);