0

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?

1 Answers1

0

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>`
Dali
  • 571
  • 1
  • 4
  • 16