I have a table and with jquery and js td are added to be necessary for the table as it is a kind of invoice that fills the user, I require that when you add the other td print on the td the button that will click to show the modal and load other expenses that you need to fill in the template
<script type="text/javascript">
$(document).ready(function(){
$("#add").click(function(){
// Obtenemos el numero de filas (td) que tiene la primera columna
// (tr) del id "tabla"
var tds=$("#tabla tr:last td").length;
var trs=$("#tabla tr").length;
var nuevaFila="<tr>";
for(var i=0;i<tds;i++){
nuevaFila+="<td> </td>";
}
nuevaFila+="</tr>";
$("#tabla").append(nuevaFila);
});
$("#del").click(function(){
var trs=$("#tabla tr").length;
if(trs>1)
{
$("#tabla tr:last").remove();
}
});
});
</script>
<div class="panel-body">
<div class="table-responsive">
<table id="tabla" class="table table-bordered table-hover" >
<thead>
<tr>
<th>ID Gasto</th>
<th>Descripción </th>
<th>Monto General</th>
<th >Opciones</th>
</tr>
</thead>
<tbody id="tbody">
<?php
require_once('./conexion.php');
$sql = "SELECT * FROM gasto_g";
$res = mysqli_query($conexion,$sql);
while($resultado = mysqli_fetch_array($res)){
?>
<tr>
<td><?php echo $resultado['id_gasto_g']; ?></td>
<td><?php echo $resultado['descripcion']; ?></td>
<td><?php echo $resultado['monto']; ?></td>
<td>
<button type="button"
data-id=<?php echo $resultado['id_gasto_g']; ?>
data-descripcion= <?php echo $resultado['descripcion']; ?>
data-monto=<?php echo $resultado['monto']; ?>
data-toggle='modal' data-target="#registro" class='btn btn-primary btn-sm'>
<i class="fa fa-pencil"></i>
</button>
</td>
</tr>