title: Javascript: Why am I getting this Uncaught TypeError: Cannot read property 'addEventListener' of null?
body: <p>I am trying to register an event handler that appends an element into the DOM when a button fires a click event,e.g.</p>
  
  <pre><code>var b = document.getElementById('evt');
  
  var eventDemo = function(event) {
  
      console.log('I handled the event');
      console.log(event);
      console.log(Object.prototype.toString.call(event)); 
  
  var imgElement = document.createElement('img');
  imgElement.src = 'http://lorempixel.com/150/150/';
  document.body.appendChild(imgElement);
  
  };
  
  b.addEventListener('onclick', eventDemo, false);
  </code></pre>
  
  <p>but I keep getting:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'addEventListener' of null</p>
  </blockquote>
  
  <p>Why is this happening</p>
  
  <p>Browser: chrome</p>