title: Google Chrome not letting me use setAttribute for ID's
body: <p>I've got some JS code here. Basically, I am trying to change the ID of an element to some value from a previous variable.</p>
  
  <p>Here's what I got so far;</p>
  
  <pre><code>function() {
    var colorarray = [ "RANDOMCOLOR_0", "RANDOMCOLOR_1", "RANDOMCOLOR_2" ];
    var RANcolorarray = colorarray[Math.rsound(Math.random() * (colorarray.length - 1))];
    document.getElementsByClassName('RANDOMCOLOR').setAttribute('id', RANcolorarray); 
  }
  </code></pre>
  
  <p>This code throws an error in Chrome for line 4: <code>Uncaught TypeError: undefined is not a function</code> which is weird because JsLint finds no errors. </p>
  
  <p>I also tried using the other way to setting id's;</p>
  
  <pre><code>document.getElementsByClassName('RANDOMCOLOR').id = RANcolorarray;
  </code></pre>
  
  <p>However, although this method does not throw an error on chrome or jslint - it does not work at all after inspecting the element.. :/</p>
  
  <p>Any ideas?</p>