Well I think I am in favor of the class solution to group similar
nodes but I'll throw this out there.
You could iterate over the event node's ancestors, build a CSS
selector based off ancestor tag names and then throw that into the $$
function and you should get a collection of nodes that are of the same
depth.
$$("html > body > div > h1 > b").each(changeColor);
Cheers,
Matt
On Jan 11, 3:45 am, Wizz <[EMAIL PROTECTED]> wrote:
> On 11 jan, 05:47, Pin <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello People,
>
> > Suppost that i have this structure:
>
> > html 0
> > / \
> > / \
> > / \
> > head 0.0 body 0.1
> > / / \
> > / / \
> > title 0.0.1 / \
> > | div 0.1.0 div 0.1.1
> > "Some" / \
> > h1 0.1.0.0 h1 0.1.1.0
> > / \
> > b 0.1.0.0.0 b 0.1.1.0.0
> > | |
> > "This" "This too"
>
> > Suppose that I dispatch an event when I stays on the "This" word, with
> > mouseover, that changes the color of this, but changes the color too
> > for the sames node in other similar "group", like "This too".
>
> > The basic question is how can to generate this string 'body div h1 b'
> > when I stays on "This" or basically how can I know the structure of
> > nodes that has this node where I stays.
>
> > Or basically what can I do..... to change color of "This too" when I'm
> > on "This" only following the DOM.
>
> > Sorry if I not very clear is really complex to explain.
>
> > Thank in advance.
>
> It might make it a lot easier if you gave similar nodes the same
> classes, even if it is just for accessing them and not styling.
>
> To take your example:
>
> <html>
> <head>
> <title>Some</title>
> </head>
> <body>
> <div>
> <h1><b class="group1">This</b></h1>
> </div>
> <div>
> <h1><b class="group1">This too</b></h1>
> </div>
> </body>
> </html>
>
> The you would be able to do something like this:
>
> $$('.group1').invoke('observe', 'click', listener);
>
> function listener(el) {
> $$('.'+el.className).invoke('addClassName', 'clickclass');
>
> }
>
> I haven't tested it, so don't shoot me if it doesn't work... but it's
> just the general idea
>
> Greetz,
>
> Wizz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---