Iterating over jQuery $(this).attr('class').split(“ ”) gives odd results?

2 +1 avoid gotchas :) stackoverflow. Com/questions/3154215/… – galambalazs Jul 5 '10 at 17:25 Also note that for..in is not guaranteed to access the indices in numeric order (see MDC) – Matthew Flaschen Jul 5 '10 at 17:25 true, fortunately it's not an issue here – galambalazs Jul 5 '10 at 17:28 ecmascript 5 will also support Array.forEach() natively, – jAndy Jul 5 '10 at 17:33 Thanks meder, that's exactly what I was looking for. Now I know!

– Sam Jul 5 '107 at 9:47.

Meder answered your question just right, i've just wanted to add, that if the order of the enumeration is not important, you can always use this simplified form: for ( var I = classes. Length; i--; ) { alert( classesi ); } It is shorter, and faster.

1 Or if you want even faster, use a negative while loop. – Anders Jul 5 '10 at 17:44 that's one more line of code, for almost no benefit. The real issue here is readability.

This form does well on every field. – galambalazs Jul 5 '10 at 17:58.

To add to the other valid answers, since you're already using jQuery, you can take advantage of jQuery. Each: $. Each(classes, function (i, class) { alert(class); }).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions