Try this by replacing .myClassName with the actual class name (but keep the period at the beginning).
$('.myClassName').each(function() { alert( this.id ); });
So, if the class is "test", you would do $('.test').each(func...
This is a concrete view of .each() that .each() over a jQuery object.
The form you used is iterating over any type of collection. So you essentially repeated the array of characters t,e,s,t .
Using this form of $.each() , you need to do it like this:
$.each($('.myClassName'), function() { alert( this.id ); });
... which will have the same result as the example above.
user113716 Aug 15 '10 at 1:26 2010-08-15 01:26
source share