title: Javascript loading before HTML page error
body: <p>I am just trying to get a very simplistic event handler working, however, 
  I keep an getting an error:</p>
  
  <pre><code>Cannot set property 'onclick' of null
  </code></pre>
  
  <p>I am suspecting this is due to my javascript executing before my HTML is finished loading. And so I've tried wrapping my javascript in each of these:</p>
  
  <pre><code>$window.onload = function(){
  $(window).bind("load", function(){
  $(document).ready(function(){
  </code></pre>
  
  <p>This is the function call causing the error:</p>
  
  <pre><code> var submit = document.getElementById("button");
  
      submit.onclick = function () {
              answer("text");
          }
  
  function answer(x){
  var response = new String("Thank you"); 
  var a = document.getElementById(x);
  a.textContent += response}
  </code></pre>
  
  <p>Any ideas?</p>