开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜