JSFiddle - React, Tailwind, and code Playground
HTML
<span><img src="http://lorempixel.com/100/100" alt="" class="" /><input type="checkbox" value="3" name="img[]" /></span> <span><img src="http://lorempixel.com/100/100" alt="" class="" /><input type="checkbox" value="1" name="img[]" /></span> <span><img src="http://lorempixel.com/100/100" alt="" class="" /><input type="checkbox" value="5" name="img[]" checked="checked"/></span>
CSS
img{border:2px solid #f00;}
img.high{border:2px solid #0f0;}
JavaScript
$('input:checkbox').each(function(){
($(this).is(':checked'))?$(this).prev().addClass('high'):'';
});
$('img').click(function() {
var $checkbox = $(this).next();
$checkbox.attr('checked', !$checkbox.attr('checked'));
$(this).toggleClass('high');
});