JSFiddle - React, Tailwind, and code Playground

by darkajax

HTML

<button id="add">Add</button>

JavaScript

var count = 0;
$("#add").on("click", function(){
    var html = '<div id="stuff">';
    count++;
    html += '<button class="remove" id="' + count + '">Remove</button>';
    html += '</div>';
    $( html ).insertBefore("#add");
});

$("body").on("click", ".remove", function(){
    $(this).remove();
});