On Dec 12, 6:07 am, Iros <imir...@gmail.com> wrote:
> The distinction between id and class is that there should only be one
> element per page with a particular id but you could have one or more
> elements with the same class.

Actually, zero or more elements with the same class :-)

>
> What you could do is find all the elements that have the class row and
> then iterate to observe each with the following syntax:

If the OP wants all the rows in the table, the table's rows collection
could be used.  If a subset of the table's rows is required, they can
be put inside a tbody and the tbody's rows collection used:

<table>
  <tbody>
    <tr>
    ...
  <tbody id="rows">
    <tr>
    ...
</table>


  var rows = $('rows').rows;


That method can also be used to guarantee that rows is a collection of
table row elements (or empty) in browsers that support the DOM
HTMLTableElement and HTMLTableSectionElement interfaces. A class-based
selector offers no such guarantee.


> $$('.row') gets all the elements. Then you can iterate on them.

You can iterate over HTMLCollections too, and they are auto-updating
so if rows are added or removed, the collection is automatically
modified to suit.


> You
> can call .size() and reference the collection at a particular index
> with $$('.row')[i]. Then attach your observers to each one of those.

All of which can be done using the built-in DOM rows collection
without the need for a CSS-based selector.

Also, the OP might consider event delegation using a single mouseover
and mouseout listener on the tbody or table rather than one on every
row.


--
Rob
--~--~---------~--~----~------------~-------~--~----~
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