JSFiddle - React, Tailwind, and code Playground

by dmitryfil

HTML

<input type="checkbox" name="item-a" checked="checked" />
<input type="checkbox" name="item-b" />
<input type="checkbox" name="item-c" />

<hr />

<select multiple>
    <option value="a">a</option>
    <option value="b">b</option>
</select>

JavaScript

$('input[type=checkbox]:checked').attr('checked', false);
//$('input[type=checkbox]:checked).removeAttr('checked');

$('select option').each(function(i, el){
    var val = $(this).attr('value');
    $('input[name=item-'+val+']').attr('checked', 'checked');
    //$('input[name=item-'+val+']').attr('checked', true);
});