Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

querySelectorAll checked values

I have a list/group of checkboxes, that made by php; put in name="item[]" html property, and then follow with this:

 var list = document.querySelectorAll("input[name^='item[']")

So far, works well. I need to count only the checked ones, not all like:

 list.length

How can I access the values for eachone to check "checked" property or value?

like image 513
Epistomai Avatar asked Jun 07 '17 16:06

Epistomai


1 Answers

Rather than looking through your list, you can go back and ask querySelectorAll to return just the checked items:

var checkedList = document.querySelectorAll("input[name^='item[']:checked")
like image 177
James Thorpe Avatar answered Sep 21 '22 13:09

James Thorpe