Hello everyone,
I have a question regarding a variable in jQuery. I put the link to the image of my code at the end of this post.
Here is my question : I have only defined var openedIndex = -1. So the value of openedIndex is -1. Now in the line 14 and 21, I use this variable to compare it with another, but it is clear that openedIndex can’t be = -1, or nothing would work. Or the code works perfectly fine.
So, if nothing happened between its definition at -1, and the part of the code where it is used, how can it be different from -1 ?
If, for example, I would have written openedIndex = $(this).children().index() … I would understand how its value can change, but here nothing of the sort happened. So I don’t understand how can it change value if no function applies such principle to it.
Can someone help me understand ?
(I hope I made myself clear, I am French so I don’t speak fluent English, sorry ^^)
Thank you
Here is the link to the image of my code :