title: Add onclick event to newly added element in JavaScript
body: <p>I have been trying to add onclick event to new elements I added with JavaScript.</p>
  
  <p>The problem is when I check document.body.innerHTML I can actually see the onclick=alert('blah') is added to the new element.</p>
  
  <p>But when I click that element I don't see the alert box is working. In fact anything related to JavaScript is not working..</p>
  
  <p>here is what I use to add new element:</p>
  
  <pre><code>function add_img() { 
    var elemm = document.createElement('rvml:image'); 
    elemm.src = 'blah.png';
    elemm.className = 'rvml';
    elemm.onclick = "alert('blah')";
    document.body.appendChild(elemm);
    elemm.id = "gogo";
    elemm.style.position='absolute';
    elemm.style.width=55;
    elemm.style.height=55;
    elemm.style.top=200;
    elemm.style.left=300;
    elemm.style.rotation=200; 
  }
  </code></pre>
  
  <p>Here is how I call this function:</p>
  
  <pre><code>&lt;button onclick=add_img()&gt;add image&lt;/button&gt;
  </code></pre>
  
  <p>Now the image draws perfectly inside the browser. But when I click the image I don't get that alert.</p>