Advertisement
jumpy83

duplicare

Mar 7th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. document.getElementById('btnAdd').onclick = duplicate;
  2. var i = 0;
  3. var original = document.getElementById('duplicater');
  4.  
  5. function duplicate() {
  6. var clone = original.cloneNode(true); // "deep" clone
  7. clone.id = "duplicetor" + ++i; // there can only be one element with an ID
  8. original.parentNode.appendChild(clone);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement