-
How to check wether the checkbox is selected or not using jquery
over 9 years ago
-
over 9 years ago
With an ID
$('#' + id).is(":checked")
If you want to check by name
var $boxes = $('input[name=thename]:checked');
where "thename" is the name of the checkbox. Checking by name come in handy if you have multiple checkboxes to check
For Example:- If you have an array of checkboxes with same name(creating a checkbox list),you can loop like following.$boxes.each(function(){ //do stuff here with this });
And for checking that how many of them are checked in the list:-
$boxes.length;
1 Answer(s)