Lee Lee - 8 months ago 34
jQuery Question

how to add counter to a class name in jquery

//if thats correct OR

I was wondering how can i add a counter to a class name in jquery like the above


It does not make any difference. In the second example you just concatenate an empty string to your class string. So both results in the same string. The following statement is true: '.balance'+i == '.balance'+i+''.

Since you does not need the second concatenation I would suggest using the first option: '.balance'+i.

Hint: You have used {} instead of () (but I think you just made a typo), so your example results in a syntax error. Correct would be: $('.balance'+i).attr();