+ 1

How to get the index of each td tag?

Im trying to get the index of each td tag when pressed... everytime I press a cell i get only 9 as the output instead of the index of that particular cell. I'm still new to JS. I would highly appreciate if someone could help me out! Here's the code: https://code.sololearn.com/Wd3qL8xU3J2t/?ref=app

26th Jun 2020, 6:47 PM
Priyan Vignesh Ramesh
Priyan Vignesh Ramesh - avatar
2 Respostas
+ 2
change var to let, its just quirky behavior of using var. basicly every event using the very same i no matter if it changes or not where as let in every itteration have a new i of that value
26th Jun 2020, 7:02 PM
Taste
Taste - avatar
0
Thank you so much! It works!
27th Jun 2020, 3:45 AM
Priyan Vignesh Ramesh
Priyan Vignesh Ramesh - avatar