title: Javascript - Add element id using for loop
body: <p>I'm trying to update a set of divs <code>class="oct_days"</code> to give them id based on <code>:nth-child(n)</code>. The format of the <code>id</code> is <code>oct_n</code>. I'm trying to accomplish this using a for loop to set this for divs. </p>
  
  <pre><code>window.onload = function addOctDate() {
      var cls = document.getElementByClass("oct_days");
      for (var n = 1; n &lt; 32; n++) {
          cls[n].id = "oct_" + n;
      }
  };
  </code></pre>
  
  <p>Fiddle (<a href="http://jsfiddle.net/ascottz/D9Exm/" rel="nofollow">http://jsfiddle.net/ascottz/D9Exm/</a>)</p>
  
  <p>The idea is to have <code>.oct_days:nth-child(1)</code> have <code>id="oct_1"</code>, but id isn't being set. </p>