title: How to add onclick to a html element dynamically using javascript
body: <p>I am able to create a button element and add an onclick event as shown below.</p>
  
  <pre><code>elem.onclick=function()
  {
  alert("qweqweqwe");
  }        
  </code></pre>
  
  <p>How do I go about using a predefined function instead of defining a function inside of the event? Something like:</p>
  
  <pre><code>elem.onclick=func();
  </code></pre>