Like you said, $$() returns and array of DOM elements. You just need
to iterate over the collection and set up the observe event on each
item. For example:

$$('.class').each(function(element) {
  element.observe('click', function() {


Robert Zotter
Zapient, LLC
Ruby on Rails Development and Consulting

On Oct 28, 9:27 pm, kimbaudi <[EMAIL PROTECTED]> wrote:
> Hi, I am having trouble with using Element.observe() with $$(). If I
> have an element with id="id", I can do this:
> $('id').observe('click', function() {alert('clicked');});
> However, if I have elements with class="class", I can't do this:
> $$('.class').observe('click', function() {alert('clicked');});
> I know that $$() returns a document-order array of extended DOM
> elements, but I have no idea how to use Element.observe() on the array
> returned by $$().  Any help will be greatly appreciated.
> - Paul

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 [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to