just use findElement() to get the first enclosing div.
It should look like this:

$$('.className'),observe('mouseover', funcToCall);

function funcToCall(e)
  var theDiv = e.findElement('.className');
  // use the div

Note that if you lots of those divs, you may consider observing the
whole document instead of each single one.
It will have some benefits like:
- only one event handler
- will work on div added to the dom after the event handler has been
- (probably) less memory leaks in IE6 :o)


On Jul 14, 8:01 pm, "Dr. Underhook" <monty.mu...@gmail.com> wrote:
> 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 <matthew.jones...@gmail.com> 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 & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to