Hudhaifa Yoosuf Hudhaifa Yoosuf - 8 months ago 49
jQuery Question

Appending variable into a string with quotes

I have a problem appending a variable to a string which is already concatenated.

var count = $("#salesdetaildata").children.length;
var data ="<td name='Data[appendhere]'></td>";

I need to append the count variable into the place where "appendhere" is.


You can add data into the string by using + signs. At least that's what I'm assuming you're after:

var count = $("#salesdetaildata").children.length;
var data ="<td name='Data["+count+"]'></td>";