[jQuery] Re: each, index to addClass

2009-12-01 Thread yskel
Thanks - that did it. I knew I was making this a lot more difficult than it needed to be. I'd actually tried something syntactically similar to what you suggested before, but it didn't work: $(".CustomClass").each(function(i){ $(this).addClass(i); }); As you pointed out, however, this w

[jQuery] Re: each, index to addClass

2009-12-01 Thread MorningZ
"but it definitely is not doing what I expect" Start by understanding that the selector value is typically a *string* value Also, the "each" function passes an index along to the event, so with those both said: $(".CustomClass").each(function(idx){ $(this).addClass("index_" + idx); });