SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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:

    $('.toggle-trigger').each(function(){
    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.

    Thanks

  2. #2
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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...


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •