If I put document.querySelector inside a loop:
for (let i=0; i<5; i++)
and I want the querySelector to get the element by id "data1" if i=1, "data2" if i=2 and so on. How can I do this?
I have tried something like this but obviously it didn't work
for (let i=0; i<5; i++) { document.querySelector("#data${i}"); }