JSFiddle - React, Tailwind, and code Playground
by Shree Khanal
HTML
<input type="checkbox" name="mark[]" id="mark1" class="mark" value="1">
<input type="checkbox" name="mark[]" id="mark2" class="mark" value="2">
<input type="checkbox" name="mark[]" id="mark2" class="mark" value="3">
JavaScript
$('.mark').click(function(index,item){
var index1 = $(this).index();
alert(index1);
if ( $(this).is(":checked") ){
alert ( $(this).val() + ' if checked' );
}
$(this).click(function() {
alert ( $(this).val() + ' click' );
});
});