0

I am getting some records in Laravel. At the bottom there is an 'Add More Rows', which clones the last row. Now what i need is when i create add new rows, i need to show a 'button' mark at the end, and if i click that, it should delete the created rows 'tbody'. How can i achieve that? My fiddle is below:

<script>
 var row = 1;
 $(function() {
 $('#AddRow').click(function(e) {
   e.preventDefault();
   var fila = $('#Fila')
    .clone()                        // CLONE THE TEMPLATE
    .attr('id', 'row' + (row++))    // MAKE THE ID UNIQUE
    .appendTo($('#Rendiciones tbody'))  // APPEND TO THE TABLE
    .show();                        // SHOW IT
  });
 $('#DeleteRow').click(function(e) {
  e.preventDefault();
  var fila = $('#Fila')
  .clone()                        // CLONE THE TEMPLATE
  .attr('id', 'row' + (row--))    // MAKE THE ID UNIQUE
  .removeAttr($('#Rendiciones tbody'))  // REMOVE FROM TABLE
  .show();  
  });
});
</script>

0 Answers0