JSFiddle - React, Tailwind, and code Playground
by chayacooper
HTML
<input type=checkbox name="baz" value="Black" > Black
<input type=checkbox name="baz" value="White" > White
<input type=checkbox name="baz" value="Red" > Red
<input type="button" value="Show Value" onclick="window.alert($('input:checkbox[name=baz]:checked').val());" />
<input type="button" value="Show Array" onclick="window.alert(selected);" />
JavaScript
var selected = new Array();
$(document).ready(function() {
$("input:checkbox[name=baz]:checked").each(function() {
selected.push($(this).val());
});
});