Count the number of checked checkboxes in HTML

后端 未结 6 888
一整个雨季
一整个雨季 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:47

    This should do the trick:

    alert(document.querySelectorAll('input[type="checkbox"]:checked').length);

提交回复
热议问题