JSFiddle - React, Tailwind, and code Playground

by babich_ss

HTML

<input id="bar" type="checkbox">
<label for="bar" id="foo">Press me</label>
<output id="out"></output>

JavaScript

foo.onclick = function(){
    var state = !document.getElementById(this.getAttribute("for")).checked; //Берёт значение до нажатия. Потому инвертируем.
    if(out.hasOwnProperty("value")){
        out.value = state;
    }else{
        out.innerHTML = state;                    
    }
}