How to get list of checked checkboxes in form using JQUERY
I have a form which have many check boxes in it. User will check one or many checkboxes and click on submit butten开发者_开发百科. So How could I get the list and count of the input box which are checked.
Please guide me friends.
// will give all the checked checkboxes in an array
var checkedCheckBoxes = $("input:checkbox:checked");
var checkedLength = checkedCheckBoxes.length;
numChecked = $(':checkbox:checked').length;
Your question is a little ambiguous. If you want a list of all checkboxes & the count of checked ones:
$cb = $(':checkbox');
numChecked = $cb.filter(':checked').length;
However, if you want a list of just the checked checkboxes, and the count of that:
$cb = $(':checkbox:checked');
numChecked = $cb.length;
精彩评论