[Solved] Set checked property of all check boxes depending on a condition without “for” or “while” loops, a jquery callback is accepted


You can use call back function, while assigning checked property for check box.

Try this below code.

var arr = [true, false, false, true];
$(".someclasss").prop("checked", function(index) {
  return arr[index];
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<input type="checkbox" id="c1" class="someclasss">
<input type="checkbox" id="c2" class="someclasss">
<input type="checkbox" id="c3" class="someclasss">
<input type="checkbox" id="c4" class="someclasss">

1

solved Set checked property of all check boxes depending on a condition without “for” or “while” loops, a jquery callback is accepted