I got this code:
<script>window.onload = function () {
 var container, i;
 for (i = 0; i < 10; i ++) {
  container = document.createElement ("div");
   container.innerHTML = i;
   container.style.border = "1px solid black";
   container.style.padding = "10px";
   container.onclick = function () {
    alert (i);
   }
  document.body.appendChild (container);
 }
}</script>
Just would like to know why I get the wrong number when I click on element :(
Thanks