Simplest way to check whether all checkbox input fields checked or not; by converting a NodeList to an Array using ES6 ...
spread operator so we can attach every()
method to it;
Checkout the Are they all checked? Demo on jsfiddle
[...document.querySelectorAll('input')].every(checkbox => checkbox.checked)
Top comments (5)
Thanks Arden! You can definitely do the same thing with
Array.from
, but in my case, the...
is better use IMO. Less code, easy to remember, plus performance. CheersAlso