Re: Using $$ within an element.

Christophe Porteneuve
Sun, 03 Jun 2007 15:54:45 -0000

Mark Holton a écrit :
> Wild.  ...can I trouble you for a short explanation on that, Chris?

Sure thing.

> $$(''#box > *:first-child a.tooltip'')

A bona-fide CSS3 selector:

	#box -> filters on a container with id="box"
	>    -> following selector must pertain on child, not descendant
	*    -> we don''t care about the tag name
	:first-child -> CSS3 pseudo-class that restricts the previous
                        selection to first children only, hence the
                        equivalence with .firstDescendant()
        (space)      -> now we can go to any depth
        a.tooltip    -> a-tag elements with a "tooltip" CSS class

> Selector.findElements($(''box'').firstDescendant(),
'' a.tooltip'')

$$(...) is basically Selector.findElements(document, ...).

This method performs the selection within the scope of the DOM node it
takes as its first argument.  So using it explicitly lets you specify
the scope.

''HTH