0

I am trying to append a new row in a table with a variable

I used this line of code with no luck

 $('.view-payments table').append('<tr><td>Amount</td><td>' grandTotal '</td></tr>');

What is the problem?

Mohammad Ereiqat
  • 165
  • 1
  • 11

1 Answers1

3

it should be

$('.view-payments table').append('<tr><td>Amount</td><td>'+grandTotal+'</td></tr>');
Pragnesh Chauhan
  • 8,363
  • 9
  • 42
  • 53
  • 1
    Not quite: http://stackoverflow.com/a/171049/139010 – Matt Ball Dec 01 '12 at 07:07
  • Yes the '+' sign was the only issue otherwise it was correct. – ankitkanojia Sep 17 '19 at 06:57
  • Altough you should use below approach to append row in table dyanmic becuase its right way to add any row to table. You can use following approach as well. $('.view-payments table').append($('') .append($('').append('Amount')) .append($('').append(' + grandTotal + ')) ); – ankitkanojia Sep 17 '19 at 07:12