// when the button (select_unit_button) is clicked it returns all the checed checkboxes values$("#select_unit_button").on("click", function(e){
var arr = [];
$(':checkbox:checked').each(function(i){arr[i] = $(this).val(); // u can get id or anything else});
//console.log(arr); // u can test it using this in google chrome});
//for one element:
document.querySelector('.myCheckBox').checked = true /* or false */ //will select the first matched element
//for multiple elements:
for (const checkbox of document.querySelectorAll('.myCheckBox')) {
checkbox.checked = true //or false
}