JSFiddle - React, Tailwind, and code Playground

by James

HTML

<label for="foo">hi</label>
<input type="checkbox" id="foo" name="checkbox" data-id="fooasdf" />

JavaScript

var checkbox = document.querySelector("input[name=checkbox]");

checkbox.addEventListener('click', function(e) {
console.log(e.currentTarget.dataset)
  if (this.checked) {
    console.log("Checkbox is checked..");
  } else {
    console.log("Checkbox is not checked..");
  }
});