Iterate through the items, read their classes and edit their appearance/animate them accordingly. For example here is a rework of your current snippet:
jQuery(document).ready(function(){
var animCounter = 0;
$("span").each(function(){
var spanClasses = $(this).attr('class');
if (spanClasses.indexOf('size-')!=-1){
var size = spanClasses.substring( spanClasses.indexOf('size-')+5 );
$(this).delay(animCounter * 500).animate({'font-size':size+'px'},500);
animCounter++;
}
});
});
This function will go through all of your spans, check if they have a size-...
class. If an element does have it - it will take the number after that and use it as a size parameter (also removing the need of the css classes).
Note that there is a delay counter, appended to each animation, so that each element will be animated at the right time.
You can do the same with color classes etc. Also you should probably rework the parsing of properties from the class name (10
out of span-10
) using regex. The current code may break if there are other classes after the span property.
Update
Here is an example using regex to parse parameter from a class attribute:
var size = spanClasses.match(/size-\d*/)[0].substring(5);
Hope this helps!