Dynamic jquery button on a table?

0
 <table id="tabla">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
  </tr>
</table>

Currently to enter data to my table use apend, how can I insert a button?

$('#tabla').append('<tr><td>'+dato+'</td><td>'+dato+'</td><td>'+dato+'</td></tr>');

I was trying this out

$('tabla').append('<input type="button" value="test" />');

But I can not insert a button greetings!

    
asked by Javier Antonio Aguayo Aguilar 20.04.2017 в 22:35
source

1 answer

0

Try inserting it into the same table:

$('#tabla').append(
 '<tr>'+
   '<td>'+dato+'</td>'+
   '<td>'+dato'</td>'+
   '<td><input type="button" value="test" /></td>'+
 '</tr>'
);

or by adding a class or id to the cell where you will add the button:

$('#tabla').append(
 '<tr>'+
   '<td>'+dato+'</td>'+
   '<td>'+dato'</td>'+
   '<td id="aquiVaElBoton"></td>'+
 '</tr>'
);

and inserting the button:

$('#aquiVaElBoton').append(
     '<input type="button" value="test" />'
);
    
answered by 20.04.2017 / 22:56
source