title: Why can't I use JavaScript getElementsByName() with [0].style...?
body: <p>If <code>getElementsByName</code> is supposed to return an indexable list of elements, why can't I reference the only element with that name using <code>[0]</code>? </p>
  
  <pre><code>mycanvas=document.createElement("canvas");
  mycanvas.width = 600;
  mycanvas.height = 400;
  ctx = mycanvas.getContext("2d");
  document.body.appendChild(mycanvas);
  
  document.getElementsByName("mycanvas")[0].style.backgroundColor="#FF0000"; //this produces an "undefined is not an object" error
  //mycanvas.style.backgroundColor="#FF0000" //this works
  </code></pre>