JSFiddle - React, Tailwind, and code Playground

by Ashish

HTML

<form id="test" action="#" method="post">
    <div>
        <input type="checkbox" name="check" id="check"/>
    </div>
</form>

CSS

.test {
    padding: 1em;
    background-color: #fffcb5;
}

JavaScript

$('#check').change(function() {

    var $check = $(this),
        $div = $check.parent();

    if ($check.prop('checked')) {
        alert("Check");
        $div.addClass('test');

    } else {
        alert("Uncheck");
        $div.removeClass('test');

    }

});