Try this
var X=0;
$('imageContainer').getElements('img').each(function(img) {
img.addClass('image'+X);
});
On Thu, Mar 11, 2010 at 3:27 PM, Aske <[email protected]> wrote:
> Hi guys.
>
> Beginner question here, trying to add a class attribute "class" with
> the value "imageX", where x is a variable, to all img's in a div.
>
> var count=0;
>
> $('imageContainer').getElements('img').each(function() {
>
> $('imageContainer').childNodes[count].set('class',
> 'image'+count);
>
> });
>
> This doesn't work, there must be an easier way. How do i select
> "this", in the loop, so i dont have to navigate down the node tree
> with "$('imageContainer').childNodes[count]"?
>
>
> Thanks in advance.
>