JSFiddle - React, Tailwind, and code Playground
HTML
<ol id="notify"></ol>
<button name="foo">Clone Me</button>
CSS
#notify {
border: 1px solid #318210;
padding: 5px;
list-style-position: inside;
background-color: #C0FAB4;
}
JavaScript
(function($) {
var checkNames = function() {
var msg = $("button").map(function(i, node) {
var txt = $(node).attr("name");
return $("<li />").text(txt)[0];
});
$("#notify").empty().append(msg);
};
var cloneField = function(ev) {
var clone = $("button:last").clone();
var name = clone.attr("name") + "x";
clone.attr("name", name).appendTo(document.body);
checkNames();
};
$(document).ready(function($) {
$("button").live("click", cloneField);
});
})(jQuery);