1
I have a table where I allow the user to insert/remove rows when they find it necessary, but what I need and am not able to adapt is to insert a block of Columns and Rows, but without success, I will try to show you what I have. I have this table:
I’m trying to add this whole block when the user clicks on Adicionar Linha, I have already made some searches and found nothing similar and my knowledge in Jquery is little, almost nothing.
The skeleton of the table is like this:
<table width="60%" border="1" id="tabela-herdeiro" class="table">
<tbody>
<tr>
<td width="8%">Nome</td>
<td width="23%"> </td>
<td width="10%">Nacionalidade</td>
<td width="27%"> </td>
<td width="10%">Estado Civil</td>
<td width="22%"> </td>
</tr>
<tr>
<td>Residência</td>
<td> </td>
<td>RG</td>
<td> </td>
<td>CPF</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Cônjuge</td>
<td> </td>
<td>RG</td>
<td> </td>
<td>CPF</td>
<td> </td>
</tr>
<tr>
<td colspan="6" align="right"><button class="btn btn-large btn-danger btn-xs" onclick="RemoveTableRowPessoa(this)" type="button">Remover</button></td>
</tr>
</tbody>
Add Line
The Jquery that inserts lines is this:
(function($) {
RemoveTableRowPessoa = function(handler) {
var tr = $(handler).closest('tr');
tr.fadeOut(400, function(){
tr.remove();
});
return false;
};
AddTableRowPessoa = function() {
var newRow = $("");
var cols = "";
cols += 'Nome Nacionalidade Estado Civil RG CPF Residênvia Cônjuge RG Cônjuge CPF Cônjuge ';
cols += '';
cols += 'Remover';
cols += '';
newRow.append(cols);
$("#tabela-herdeiro").append(newRow);
return false;
};
})(jQuery);
But I couldn’t adapt, like I said

tries to make a clone and then an append.
– Jasar Orion
maybe this question can help you. https://answall.com/questions/37731/como-remover-tabela-generatedstring
– Iago Carvalho