JSFiddle - React, Tailwind, and code Playground

by Rhys O'Connor

HTML

<form>
    <p>
        <label>Name:</label> <input type="text">
        <label>Age:</label> <input type="number">
        <span class="remove">Remove</span>
    </p>
    <p>
        <span class="add">Add fields</span>
    </p>
</form>

JavaScript

$(".add").click(function() {
    $("form > p:first-child").clone(true).insertBefore("form > p:last-child");
    return false;
});

$(".remove").click(function() {
    $(this).parent().remove();
});