1st answer: I wanted to know if there was a selector syntax that can also operate on the chosen node instead of starting search on the children. In this case it was important that I know whether ".foo", and I wanted to know if I could include it in the selector or if I needed to use .hasClass()
Your other information about why the selector is inefficient is useful but leads me to some follow-up questions. If this:
$("td.firstcol", jRowhtml);
is equivalent to this
$(jRowhtml).find("td.firstcol");
and would be more efficient as
$("td.firstcol", jRowhtml[0]);
does that mean that the other syntax would be more efficient as
$(jRowhtml[0]).find("td.firstcol");
?
I guess I will run some profile tests. I guess I don't understand why there would be a context parameter that can accept an object created from a jQuery selection that doesn't look to see if it can use that [0] element to be more efficient.
2nd answer: Maybe I'm missing something, but wouldn't left to right be more efficient in general? For instance, "tr td"; in most tables, there are going to be far less rows than cells. I guess I've been using "tr td" assuming it was shorthand for $("tr").children("td"), but if not then I will have to change my ways. Useful information!
3rd answer: I agree with your statement about design, but my point was that selecting "div.green" is going to select every element in the DOM that has that class, whereas if I could change the div.green rule directly, I would only be changing one thing in the DOM. And again, this may only apply to me, but I would like to be able to change all the elements that have a particular color (I have some color-blindness) so my selector in your function would be
$("*").filter( ..
I just imagine that looking through all the html elements in the DOM for that color isn't as efficient as looking through the stylesheets for the rules that set that color.
Thanks for your answers.