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