JSFiddle - React, Tailwind, and code Playground
HTML
<div id="items"></div>
JavaScript
var items = [1,2,3,4,5,6,7,8,9,10,11,12];
for (i in items) {
newdiv = document.createElement("div");
//newdiv.setAttribute("class","box");
//newdiv.setAttribute("id",items[i]);
//newdiv.setAttribute("ondblclick","chkItem("+items[i]+");");
newdiv.className = "box";
newdiv.id = items[i];
newdiv.ondblclick = function() {alert(this.id)}
newdiv.innerHTML = " " + items[i];
document.getElementById("items").appendChild(newdiv);
}