title: JavaScript getElementByID() not working
body: <p>Why does <code>refButton</code> get <code>null</code> in the following JavaScript code?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
          var refButton = document.getElementById("btnButton");
  
          refButton.onclick = function() {
              alert('I am clicked!');
          };
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1"&gt;
      &lt;div&gt;
          &lt;input id="btnButton" type="button" value="Click me"/&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>