JSFiddle - React, Tailwind, and code Playground

by Neal

HTML

<input type='checkbox'/>
<input type='checkbox'/>
<input type='checkbox'/>
<input type='radio'/>
<input type='radio'/>
<input type='radio'/>

CSS

.checked {
    background: red;
    width: 50px;
    height: 50px;
    display: block;
    line-height: 50px;
    border: solid 2px red;
}

JavaScript

$("input:checkbox, input:radio").change(function ()
   {
       if (this.checked)
      {
         $(this).addClass("checked");
      }
      else
       {
         $(this).removeClass("checked");
       }
   });