Not getting the right event. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Not getting the right event.

<span class='close-button ind${i}' onclick="toggleModal1(this)">×</span> The "i" value ranges from 0 to 27 and my toggleModal1 function goes like this: function toggleModal1(event) { console.log(event); } whenever I click the "x" with some class, ind{x}, I'm always getting the span with class ind0, why ?

21st Dec 2022, 3:19 PM
Hima
Hima - avatar
3 Answers
+ 1
The most likely reason you are getting ind0 is that variable i is not incremented. Show your code, you may get more community members to respond, increasing your chances of getting a better solution.
21st Dec 2022, 6:12 PM
ODLNT
ODLNT - avatar
+ 1
Interesting, I wish I could see your code.
21st Dec 2022, 6:32 PM
ODLNT
ODLNT - avatar
0
ODLNT , that's not the reason though . each span has a diff ind+x class.
21st Dec 2022, 6:13 PM
Hima
Hima - avatar