title: Using addListener to an element that would be created later
body: <p>I get an error '.addListener is not a function' upon trying this:  </p>
  
  <pre><code>if(document.getElementById("id")){
     document.getElementById("id").addListener('click', function(){alert("ok");});
  }
  </code></pre>
  
  <p>This element 'id' comes into picture when the entire document gets loaded, and I am using it in the middle of the documents construction. So, I did this:  </p>
  
  <pre><code>window.onload = function(){
                  if(document.getElementById("id")){
                     document.getElementById("id").addListener('click', function(){
                     alert("ok");
                     });
                  }
  }
  </code></pre>
  
  <p>The error is gone now, but the element 'id' does nothing upon being clicked.<br>
  How to make it clickable?</p>