I wanted to concatenate the value of variable i
to string item
. i tried like below but it's not working. How can i achieve this?
var tableString = "<td><input type='text' id='item' i><td>"
i've already gone through this link: Put quotes around a variable string in JavaScript . Can i get some help on this?
CodePudding user response:
If you want to use variables inside string, you have to use template literal like this.
var tableString = `<td><input type='text' id='item${i}'><td>`