JSFiddle - React, Tailwind, and code Playground
by Sean Wessell
HTML
<input type="checkbox" id="check1" data-count="0" /><label>Option1</label>
<input type="checkbox" id="check2" data-count="0" /><label>Option2</label>
<input type="checkbox" id="check3" data-count="0" /><label>Option3</label>
<input type="checkbox" id="check4" data-count="0" /><label>Option4</label>
<input type="checkbox" id="check5" data-count="0" /><label>Option5</label>
<div id="output"></div>
JavaScript
$(':checkbox').click(function () {
var $this = $(this);
if (typeof ($this.data("count")) == 'undefined') {
$this.data("count", 0);
};
if ($this.is(":checked")) {
$this.data("count", $this.data("count") + 1)
//alert($this.data("count"));
}
$("#output").html("");
$(":checkbox").each(function(){
$("#output").append(this.id + " clicks = " + $(this).data("count") + "<br />")
})
});