.each(img, index){ ...

On 11 Mar 2010, at 13:47, Slik Jay wrote:

> different classes for imgs:
> var X=0;
> $('imageContainer').getElements('img').each(function(img) {
>    img.addClass('image'+(X++));
> });
> 
> On Thu, Mar 11, 2010 at 3:44 PM, Barry van Oudtshoorn
> <[email protected]> wrote:
>> Or even just
>> 
>> var x = 'pony';
>> $('imageContainer').getElements('img').addClass('image' + x);
>> 
>> Any collection of elements returned by MooTools is extended with the Element
>> methods: http://mootools.net/docs/core/Element/Element#dollars
>> 
>> On 11/03/2010 9:39 PM, Slik Jay wrote:
>>> 
>>> 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.
>>>> 
>>>> 
>> 
>> 
>> --
>> Not sent from my Apple πPhone
>> 
>> 

Reply via email to