Russell Keith wrote:
> I am building a css table using div elements.  I am trying to observe
> all the DIVs with a class name of oddRow but I keep getting JS errors.
> This is my first attempt at observing an entire class.  Can someone
> please point me in the right direction.  I thought the $$ method
> returned an array so I would need to iterate through with .each but I
> seem to running up against a brick wall.  Any help would be greatly
> appreciated.
> 
>  
> 
> document.observe('dom:loaded', function(){
> 
>                 $$('.oddRow').each.observe('click', function(){
> 
>                                 alert('test');        
> 
>                 });
> 
> });
Hi Russell,

each is a method of Enumerable (and thus, Arrays).  It invokes its
iterator-function for every member of the Enumerable, passing them as
first argument.  Like this:
    $$('.oddRow').each (function (odd_row_elem) {
        odd_row_elem.observe ('click', function(){
            alert('test');
        });
    });
odd_row_elem will be set to each found .oddRow Element in turn.

Have fun
----Daniel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to