JSFiddle - React, Tailwind, and code Playground
HTML
<ul role="menu" class="dropdown-menu" id="comp">
<li>
<a href="#">
<input type="checkbox" id="a1">
<span class="lbl"> Monday</span>
</a>
</li>
<li>
<a href="#">
<input type="checkbox" id="a2">
<span class="lbl"> Tuesday</span>
</a>
</li>
<li>
<a href="#">
<input type="checkbox" id="a3" checked="checked">
<span class="lbl"> Wednesday</span>
</a>
</li>
<li>
<a href="#">
<input type="checkbox" id="a4">
<span class="lbl"> Thursday</span>
</a>
</li>
<li>
<a href="#">
<input type="checkbox" id="a5">
<span class="lbl"> Friday</span>
</a>
</li>
</ul>
JavaScript
$(function() {
var checkedItems = $("#comp input:checked");
console.log(checkedItems);
$("#comp input[type='checkbox']").change(function() {
if ($(this).attr("checked") == "checked") {
checkedItems.push($(this)[0]);
console.log(checkedItems);
} else {
checkedItems.splice($.inArray($(this)[0], checkedItems), 1);
console.log(checkedItems);
}
})
})