title: Javascript place random object/images in a grid
body: <p>I'm trying to place random object in a dynamic grid using only javascript. I'm stuck on how to place random objects/images in the grid. Something like minesweeper but looking for simple example to start with. </p>
  
  <p>This is the link of the post I was following <a href="https://stackoverflow.com/questions/11083345/creating-a-dynamic-grid-of-divs-with-javascript">Creating a dynamic grid of divs with Javascript</a></p>
  
  <p>Code below:</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt; 
  &lt;script language="javascript"&gt; 
  function genDivs(v){ 
    var e = document.body; // whatever you want to append the rows to: 
    for(var i = 0; i &lt; v; i++){ 
      var row = document.createElement("div"); 
      row.className = "row"; 
      for(var x = 1; x &lt;= v; x++){ 
          var cell = document.createElement("div"); 
          cell.className = "gridsquare"; 
          cell.innerText = (i * v) + x;
          row.appendChild(cell); 
      } 
      e.appendChild(row); 
    } 
    document.getElementById("code").innerText = e.innerHTML;
  
   }
   &lt;/script&gt; 
   &lt;/head&gt; 
  &lt;body&gt; 
    &lt;input type="button" onclick="genDivs(6)" value="click me"&gt; 
     &lt;code id="code"&gt;&lt;/code&gt;
  &lt;/body&gt; 
  &lt;/html&gt; 
  </code></pre>