Dynamically creating a unique variable name for elements with same class name?

I am probably going about this all wrong, but I’m not sure how to do this.

Basically I need to create a unique variable name for each element that has the same class name and set each one to zero.

I thought I could just concatenate the index value to a variable name to create unique names. Something like:

var toggleTriggerIndex = $(‘.toggle-trigger’).index(this);
var t + toggleTriggerIndex = 0;

But apparently that’s not possible. Anyone want to point me in the right direction?

btw, all I’m trying to do is have unique variables so I can give an open/closed state to each element that uses slideToggle, so I can manipulate a plus/minus graphic.


I’m an idiot… I just realized all I had to do was use jquery’s toggle function and be done with it. What a waste of 2 hours. Nothing to see here, move along…