JSFiddle - React, Tailwind, and code Playground

by Saumil Soni

HTML

<input class="texts" type="checkbox" value="a">A
<input class="texts" type="checkbox" value="b">B
<input class="texts" type="checkbox" value="c">C
<script>
    var classname = document.getElementsByClassName("texts");
    for (var i = 0; i < classname.length; i++) {
        classname[i].addEventListener('click', myFunction);
    }

    function myFunction(e) {
    
        //accessing checked value of the textbox
        var val = e.target.value;
        alert(val);
    
        //do whatever you want with "val"
    
    }
</script>