JSFiddle - React, Tailwind, and code Playground
HTML
<button>Clone!</button>
<div id="clone0">Initial</div>
CSS
div {
width: 100px;
height: 20px;
font-family: "Helvetica", "Lucida Sans", "Lucida Sans Unicode", "Luxi Sans", Tahoma, sans-serif;
font: 10px;
padding: 5px;
border: 1px solid #ccc;
margin: 5px;
background-color: #444;
color: #eee;
}
JavaScript
$('button').click(function(){
var counter = $('div').length;
if (counter < 6) {
$('#clone0')
.clone(true)
.insertAfter($('#clone0'))
.attr('id','clone'+counter-1)
.text(counter);
}
arguments.callee.counter = arguments.callee.counter+1||0;
$(this).text('Clone '+arguments.callee.counter);
});