g(..).select(cssQuery)

Performs a gimme query as would the g(..) function, but using element 0 from the Gimme Object's underlying array as the root for the css query.

Returns: Itself (the same Gimme Object is return so additional methods can be chained together seamlessly).
Params:
  • cssQuery, required: A string in valid CSS selector syntax, which indicates which element(s) are to be retrieved.

Examples:
// Set the opacity of all <p> elements that are descendants of <li> elements
// that are children of #main, when said <li> event is moused over.
g('#main > li').addEvent('mouseover', function(e)
{
	// Wrapping the "this" object (the current <li> being moused over)
 	// in a g(..) call makes it a Gimme Object up on which we can call select(..).
	// Then, calling .select('p') ensure that we're only selecting <p> elements
	// that are descendants of that <li>, and not all <p> elements.
	g(this).select('p').setStyle('opacity', .5);
});



Related Information:
  • Note that .select(..) does not traverse all elements from the Gimme Object's underlying array, only the first element. This is consequential in that:
g('div p')

is not the same as:

g('div').select('p')

The first code snippet finds all <p> elements that are descendants of <div> elements.

The second code snippet only finds <p> elements that are descendants of the first <div> element in the DOM.

Last edited Jan 10, 2008 at 4:41 AM by sstchur, version 4

Comments

No comments yet.