title: Adding onclick event on dynamic checkbox
body: <p>I'm trying to make a 'CRUD' in pure Javascript, it's almost done, the only thing that I need is preparing the inputs with the value of <code>&lt;li&gt;</code>, to do it, I'd like to add an <code>onclick</code> event in a checkbox that is created dynamically in the function <code>insert()</code>, but everytime I click the checkbox nothing happens.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
      window.onload = function(){
          btnInsert = document.getElementById("btnInsert");
          btnEdit = document.getElementById("btnEdit");
          btnDelete = document.getElementById("btnDelete");
          vname = document.getElementById("tbName");
          ul = document.getElementsByTagName("ul")[0];
  
          btnInsert.onclick = insert;
          btnDelete.onclick = remove;
      }
  
      function insert(){
          li = document.createElement("li");
          li.innerHTML = vname.value;
          li.innerHTML += " &lt;input type='checkbox' onclick='select()'          value='Select' /&gt; Update"; 
          ul.appendChild(li);
          vname.value = "";
      }
  
      function select(){
          alert("Checked");
      }
  
      function remove(){              
          var lis = document.getElementsByTagName("li");
          for(i = 0; i&lt;lis.length; i++){
              lis[i].onclick = function(){
              this.remove();
          }
      }
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;label for="tbName"&gt;Name: &lt;/label&gt; 
  &lt;input name="tbName" id="tbName"/&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;button id="btnInsert"&gt;Insert&lt;/button&gt; 
  &lt;button id="btnEdit"&gt;Edit&lt;/button&gt; 
  &lt;button id="btnDelete"&gt;Delete&lt;/button&gt;
  &lt;br /&gt;&lt;br /&gt;
  &lt;ul&gt;
  &lt;/ul&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>