JSFiddle - React, Tailwind, and code Playground

by goldfingerxyz

HTML

<button id="button" class="button" onlick="duplicate()">Click me</button>

<div id="duplicater"> 
    duplicate EVERYTHING INSIDE THIS DIV
</div>

JavaScript

document.getElementById('button').onclick = duplicate;


var i = 0;
var original = document.getElementById('button');

function duplicate() {
    var clone = original.cloneNode(true); // "deep" clone
    clone.id = "button" + ++i; // there can only be one element with an ID
    original.parentNode.appendChild(clone);
}