JSFiddle - React, Tailwind, and code Playground

by WilsonPage

HTML

<form>
    <input type='checkbox' name='one'/>
    <input type='checkbox' name='two' checked='true'/>
    <input type='checkbox' name='three'/>
</form>

JavaScript

var 
    
form,
checkboxes,
checked = [];


form = document.querySelector('form');
checkboxes = form.querySelectorAll('input[type=checkbox]');


Array.prototype.forEach.call(checkboxes, function(checkbox) {
    
    if(!checkbox.checked) return;
    
    checked.push({name: checkbox.name});
});

console.log(checked);