JSFiddle - React, Tailwind, and code Playground
HTML
<button id="btnDept">select Depts</button>
<div id="dialog" title="Select the Depts you want to include in the report" style="display:none;">
<div>
<div>
<label for="ckbx2">2</label>
<input type="checkbox" id="ckbx2" />
<div >
dasda
</div>
<label for="ckbx3" id="lbl3">3</label>
<input type="checkbox" id="ckbx3" />
<div>
sdfsdaf
</div>
</div>
</div></div>
JavaScript
$("#btnDept").click(function () {
$("#dialog").dialog({
modal: true
});
});
function getChecked() {
var deptsSelected = [];
$('#dialog :checked').each(function() {
deptsSelected.push( this.id.split('ckbx')[1] );
});
alert( deptsSelected );
}
$('#dialog').find('input').change( getChecked );