LET LOOP
The CSS
<style> #box { display: flex; justify-content: space-around; } #box &ht; div { height: 5em; width: 5em; background-color: purple; } </style>
The JavaScript code
var div; var box = document.getElementById("box"); for (let i=0; i<5; i++) { div = document.getElementById("") div.onclick = function() { "This is box # " + i); } box.appendChild(div); } </script>