Estoy recorriendo una HTMLCollection como esta:
elements.forEach((element) => { // If all elements in the collection have a "checked" property of "true" if (?) { // Not sure what the check should be here, something like `element.checked.every(Boolean)`? // Do stuff } });¿Es posible escribir un cheque para determinar si todos los niños tienen una propiedad con el mismo valor? ¡Gracias!
Puede usar la sintaxis extendida para convertir NodeList/HTMLCollection en una matriz, luego use Array.every para verificar si cada elemento de la matriz coincide con la condición en la devolución de llamada:
const res = [...document.querySelectorAll('input')].every(e => e.checked) console.log('All checkboxes checked?', res) <input type="checkbox" checked> <input type="checkbox" checked> <input type="checkbox" checked>