JSFiddle - React, Tailwind, and code Playground
HTML
<div id='container'></div>
CSS
.checkBtn{
background-color:#cccccc;
-moz-border-radius:2px;
-webkit-border-radius:2px;
border-radius:2px;
border:2px solid #cccccc;
display:inline-block;
color:#ffffff;
padding:15px;
text-decoration:none;
margin-left: 20px !important;
}
JavaScript
var numbers = ['one', 'two', 'three', 'four'];
var container = document.getElementById('container');
for (var i = 0; i < numbers.length; i++){
//with each checkbox we want to log a different element in the array.
var checkbox = document.createElement('div');
checkbox.setAttribute('class','checkBtn');
var save = function(){
console.log(numbers[i]);
}
$(checkbox).click(function(){
save();
});
container.appendChild(checkbox);
}