title: Javascript - Add button with onClick attribute dynamically
body: <p>I am using this code, which adds button:</p>
  
  <pre><code>document.getElementById("items").innerHTML=document.getElementById("items").innerHTML+
  ('&lt;input type="button" value="'+document.getElementById("add").value+'"&gt;&lt;br&gt;');
  </code></pre>
  
  <p>It works. Now i am adding <code>onClick</code> attribute:</p>
  
  <pre><code>document.getElementById("items").innerHTML=document.getElementById("items").innerHTML+
      ('&lt;input type="button" onClick="alert("'+document.getElementById("add").value+'")"
       value="'+document.getElementById("add").value+'"&gt;&lt;br&gt;');
  </code></pre>
  
  <p>I want to display an alert with button name (<code>add</code> is button id) if I click on button. But no alert displayed. Probably I made i mistake in <code>onClick</code>, because button is being added.<br>
  Whats wrong with my code?</p>