title: How can I duplicate a button inclusive its functions with JavaScript?
body: <p>I have a button which appends some elements. I want a button which duplicates this button.</p>
  <p>I found some articles about <code>clone()</code>, but I believe that's jQuery?</p>
  <p>I can't seem to find the answer but I thought something like this:</p>
  <pre><code>var copybutton = create(&quot;input&quot;);
      copybutton.type = &quot;button&quot;;
      copybutton.id = &quot;copybutton&quot; + counter;
      copybutton.value = &quot;copybutton&quot;;
      addEvent(copybutton, &quot;click&quot;, duplicatefunction);
  
  function duplicatefunction()
  {
  var duplicatebutton = appendbutton.cloneNode (true);
  }
  </code></pre>
  <p>Well at least that would make sense to me a little, but of course it doesn't work. How can I do this?</p>