JSFiddle - React, Tailwind, and code Playground

by kidino

HTML

<script id="tpl"><tr><td></td></tr></script>
<button>add row</button>
<table width="100%" border="1">
    <tr>
        <td>the table</td>
    </tr>
</table>

JavaScript

var counter = 0;

$("button").on('click', function(){
    counter++;
    $('table').append( $('#tpl').html() );
    $('table tr:last-child>td').html(counter);
});