JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Test</h1>
<span>
<input type="checkbox" name="chk['3']" value="1" id="chk['3']-1"/>
<label for="chk['3']-1">Checkbox Option</label>
<div id="msg">initial load</div>
</span>
JavaScript
$('label').each(function() {
$('#msg').text($(this).attr('for'));
try {
var ckBox = $("#"+$(this).attr('for').replace(/(\W)/g,"\\$1"));
$('#msg').html("passed-" + ckBox[0].id);
} catch(ex) {
$('#msg').html("failed-" + ex);
}
});