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?

0

1 Answer 1

3

it should be

$('.view-payments table').append('<tr><td>Amount</td><td>'+grandTotal+'</td></tr>');
Sign up to request clarification or add additional context in comments.

3 Comments

Yes the '+' sign was the only issue otherwise it was correct.
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($('<tr>') .append($('<td>').append('Amount')) .append($('<td>').append(' + grandTotal + ')) );

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.