title: Javascript: setting / getting elements by their ID
body: <p>I haven't dealt with javascript in a long time, so please bear with me if my question seems silly.</p>
  
  <p>I am trying to create an image, set its ID, and then try to 'get' the element, I always come up with 'null'</p>
  
  <pre><code>  var gearImg = new Image();
    gearImg.id = "logoGear";
    gearImg.src = "img/gear-fun.png";
  
    var gear = document.getElementById("logoGear");
    // null?
    alert(gear);
  </code></pre>
  
  <p>If I have an actual image in my HTML with the id set, then 'getElementByID' works as expected.  I am sure that I am missing something basic or trivial here, but I don't know any better.  What is going on, and how do I get the behaviour that I want.</p>