JSFiddle - React, Tailwind, and code Playground
HTML
<div id='LabBox'>
<img alt="dontlike" name="dlike" src="images/dontlike_OFF.png" />
<img alt="check" name="check" src="images/check_OFF.png" />
<img alt="funny" name="funny" src="images/funny_OFF.png" />
<img alt="idea" name="gidea" src="images/idea_OFF.png" />
<img alt="imp" name="imptt" src="images/imp_OFF.png" />
</div>
<button id="sendLabForm"></button>
JavaScript
$("#LabBox img").click(function () {
$(this).data('select', true);
});
$("#sendLabForm").click(function () {
var selectedImgs = [];
$("#LabBox img").each(function () {
$(this).data('select') ? selectedImgs.push(this.name) : false;
});
alert(selectedImgs.join(','));
});