My approach would be something like:

$$('.className').invoke('observe','mouseover', function(e)
{ alert('mouseover element with id: ' + e.findElement().id); });

$$('.className').observe() is not correct, because observe() is
expecting a single element, whereas invoke() takes the entire array of
elements and applies the observer to each element.

e.findElement() will return the element the event was fired from, so
you can do anything you want to the element w/o it necessarily having
an id

On Jul 9, 9:50 pm, Matt <> wrote:
> Hello, I am trying to figure out how to reference a specific div after
> it has been mouseOver, when i have an observe on a class-name that a
> bunch of div's share. The reason for this i want the code to be
> expandable where i can have multiple boxes with the same class,
> sharing all CSS properties, without having to sequentially id each
> div, and have X amount of observes; one for each specific div.
> So the basic JS would be something like:
> $$('.className'),observe('mouseover',
> funcToCall(way_to_reference_div) );
> with a bunch of div's coded in html like:
> <div class="className"></div>
> <div class="className"></div>
> <div class="className"></div>
> ...
> i understand if i have to add an id to each specific div, but i want a
> way to reference the id from a single observe statement that works for
> all div's sharing that class.
> Thanks,

You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to