JSFiddle - React, Tailwind, and code Playground
by kiokotzu
HTML
<form action="">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
</form>
JavaScript
$(function(){
var check = $("form input[type=checkbox]");
$('form input[type=checkbox]').click(function(){
var index = $(this).index();
if($(this).is(':checked')){
for(var i = 0 ; i < check.length; i++){
if(i < index){
$(check[i]).prop('checked',this.checked);
console.log('for '+i)
}
}
}else{
$(check).attr('checked', false);
}
})
})