JSFiddle - React, Tailwind, and code Playground

by Serge Zahharenko

HTML

<label><input type="checkbox"/> label 1</label>
<label><input type="checkbox"/> label 2</label>

CSS

label {display:inline-block;}
label.checked {background:red;}

JavaScript

$(document).ready(function(){
    
$('label').click(function(){
    var l = $(this);
    var checked = l.children('input').prop('checked');
    checked ? l.removeClass('checked') : l.addClass('checked');
    l.children('input').prop('checked',!checked);
})
    
})