JSFiddle - React, Tailwind, and code Playground

by Md Shah

HTML

<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />

JavaScript

jQuery(document).ready(function() {
                          
var bitString = "01011";   /** Assume this is coming from a db andd that part is working **/
var next = -1;

 /** I iterate thru every check box **/ 
 $('input[type=checkbox]').each(function ()
  {
     next++;                               
     var nextChar = bitString.charAt(next);   /** Get every character from the string **/
     /** If the char is a '1', then check the check box **/ 
      if (nextChar == '1'){
           $(this).attr('checked','checked');
      }
   });
});