-1

How can I write this so it works?

document.getElementById("td-`${i}`")
Mureinik
  • 297,002
  • 52
  • 306
  • 350
vturkovic
  • 117
  • 2
  • 8

1 Answers1

2

You should use a template literal instead of the quoted string, not inside it:

document.getElementById(`td-${i}`)
// Here ----------------^-------^
Mureinik
  • 297,002
  • 52
  • 306
  • 350