title: Simple JavaScript chess board
body: <p>Could anyone give me a hint on how to generate a chess board (8x8) using JavaScript, using a table tags or ?</p>
  
  <p>I've got the following so far:</p>
  
  <pre><code>&lt;DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style&gt;
  
  div
  {
  border:1px solid black;
  width:20px;
  height:20px;
  }
  
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  
      // create a chess table 8x8.
  
      var count = 0;
  
  while (count &lt; 64)
      {
  
      if (count % 2 == 0)
  
          {
  
          if (count % 8 == 0 &amp;&amp; count !=0)
              {
              document.write('&lt;br/&gt;&lt;div style="background-color:#000000;float:left;"&gt;&amp;nbsp&lt;/div&gt;');
  
              }
          else    
              {
              document.write('&lt;div style="background-color:#000000;float:left;"&gt;&amp;nbsp&lt;/div&gt;');    
              }
          }
  
      else
  
          {
          document.write('&lt;div style="background-color:#FFFFFF;float:left;"&gt;&amp;nbsp&lt;/div&gt;');
          }
      /*  
      */          
      count++;
      }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I tried to assign black and white to each odd and even number respectively, but it doesn't work this way.</p>
  
  <p>Thank you in advance.</p>