Count the number of checked checkboxes in HTML

后端 未结 6 903
一整个雨季
一整个雨季 2020-12-10 01:13

So basically i want to count the number of checkboxes that are ticked. I get my code to the point where it counts them successfully, but I want to put in an alert that shows

6条回答
  •  一个人的身影
    2020-12-10 01:38

    try this using jquery

    Method 1:

    alert($('.checkbox_class_here :checked').size());
    

    Method 2:

    alert($('input[name=checkbox_name]').attr('checked'));
    

    Method: 3

    alert($(":checkbox:checked").length);
    

提交回复
热议问题