JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" id='col1' value='col1'/>
<input type="checkbox" id='col2' value='col2'/>
<input type="checkbox" id='col3' value='col3'/>
JavaScript
var colState = (localStorage["colState"]) ? JSON.parse(localStorage["colState"]) : [];
$("input[type='checkbox']").each(function() {
if ($.inArray($(this).attr('id'), colState) >= 0) {
$(this).attr('checked', true);
}
});
$("input[type='checkbox']").change(function() {
var colVal = $("input:checkbox:checked").map(function() {
return $(this).val();
}).get();
localStorage['colState'] = JSON.stringify(colVal);
});