Thanks all for your help :)
I think that it was the indexOf  that I was missing in all my various
attempts.

Using getNext(), whilst it works in my example in mooshell, won't
actually work in my actual code as the elements aren't "together".

Cheers,
Chris

On 10 feb, 22:30, Ryan Florence <[email protected]> wrote:
> I'd personally create the arrays and do the indexOf in this scenario.
>
> But there's a chance the actual use case could call for storing the  
> answers with the questions then simply retrieving the element using  
> el.store and el.retrieve.
>
> On Feb 10, 2010, at 2:04 PM, אריה גלזר wrote:
>
> >http://mootools.net/shell/K55zK/3/
> > this in an event always points to the element.
> > knowing that, here are 2 solutions for this that i can think of:
> > 1. creating a questions array and using indexOf
> > 2. using getNext() to fetch the nearest answer
>
> > both are shown in the example above.
> > -----------
> > אריה גלזר
> > 052-5348-561
> > 5561
>
> > On Wed, Feb 10, 2010 at 22:41, cbolson <[email protected]> wrote:
> > Is it possible to get the index of the element (eg) clicked when using
> > event delegation?
>
> > Here is my example code:
>
> > var comments=$$('.answer').hide();
>
> > document.id('faq').addEvent('click:relay(.question)', function(){
> >        // how to get the "index" of the item clicked so that this
> > next line will work?
> >       comments[index].show();
> > });
>
> > Code in mooshell:
> >http://mootools.net/shell/kss2C/
>
> > Thanks in advance for any suggestions, I am probably missing something
> > obvious :(
>
> > Chris

Reply via email to