title: how to 'getelementsbytagname.onclick'
body: <p>I am trying to get my <code>cloneNode</code> to append the <code>input</code> tag and give it a new <code>onclick</code> value.  Its just the <code>input.onclick = function(){clicker(iden);};</code> that doesn't work.  The sole purpose of this example is to change the onclick tag like I managed to change the ID.  Can anyone please help?</p>
  
  <p><strong>Script</strong></p>
  
  <pre><code>&lt;script&gt;
    iden = 0
  
    function clicker(x) {
      iden++
  
      var ent = document.getElementById('ent').cloneNode(true);
  
      ent.id = "ent"+iden;
      var input = ent.getElementsByTagName('input')[0];
  
      input.id = "inp"+iden;
      input.onclick = function(){clicker(iden);};
  
      document.body.appendChild(ent);
    }
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Body</strong></p>
  
  <pre><code>&lt;body&gt;
    &lt;div id="ent"&gt;
      &lt;input id="inp" onclick="clicker()"&gt;
    &lt;/div&gt;
  &lt;body&gt;
  </code></pre>