JSFiddle - React, Tailwind, and code Playground
by csnsgiri
HTML
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Age
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Nithin
</td>
<td>
24
</td>
</tr>
</tbody>
</table>
<button id="btn">add row</button>
JavaScript
$(document).ready(function() {
$('button#btn').click(function() {
var new_row = $('<tr>');
var input_name = $('<input>').attr({
type: 'text',
placeholder: 'Your Name',
name: 'names[]'
});
var input_age = $('<input>').attr({
type: 'text',
placeholder: 'Your Age',
name: 'ages[]'
});
var column_name = $('<td>').append( input_name );
var column_age = $('<td>').append( input_age );
new_row.append( column_name ).append( column_age );
$('table').first().find('tbody').append( new_row );
});
});