Count the number of checkboxes selected without reloading the page?

后端 未结 2 812
轮回少年
轮回少年 2020-12-17 07:06

I\'m expanding further on this question.

I currently have an asp.net hyperlink for Select All (NumberOfCheckBoxes) which works, but what I\

相关标签:
2条回答
  • 2020-12-17 07:29

    Try this:

    var inputElems = document.getElementsByTagName("input"),
        count = 0;
    for (var i=0; i<inputElems.length; i++) {
        if (inputElems[i].type === "checkbox" && inputElems[i].checked === true) {
            count++;
        }
    }
    
    0 讨论(0)
  • 2020-12-17 07:30

    With jQuery you can:

    $("input:checkbox:checked").length;
    
    0 讨论(0)
提交回复
热议问题