JSFiddle - React, Tailwind, and code Playground

by Murali Kaliappan

HTML

<div id="myDiv">
  <input type="checkbox" value="first" />
  <input type="checkbox" value="second"/>
  <input type="checkbox" value="third"/>
  <input type="checkbox" value="fourth"/>
</div>

JavaScript

$("#myDiv input[type='checkbox']").click(function(){	  
  
  $("#myDiv input[type='checkbox']").each(function () {
    if (this.checked) {
      console.log($(this).val()); 
    }
	});
  
  
})