Hey Benjamin,
For :contains(), the matching text can appear in the selector element
or in any of that element's descendants [1]. Since you don't
precede :contains with a selector element, it assumes the universal
selector (*). So, it looks like it's doing what I would expect. In
fact, it should be selecting HTML, BODY, and any other elements that
contain those cells.
If you just want to select table cells, why not do $
('td:contains(Cell)') ?
[1] Had to look this up to be sure, even though I wrote it in jQuery
Reference Guide, page 34. Sigh.
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Nov 24, 2007, at 9:09 PM, Benjamin Sterling wrote:
Hey guys,
Wanted to make sure I am getting the correct returned elements.
Assume I have a table like:
<table cellpadding="3" cellspacing="0" border="1"
width="100%">
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
<td></td>
<td>Cell 6</td>
</tr>
</tbody>
</table>
And then I run a piece a code like:
$(":contains('Cell')").css("background", "#ff0");
In my mind, I should only be getting back the TDs with "Cell" in it,
but this is not the case. the TABLE, TBODY, TR and TD are all
getting a background collor of FF0.
Am I correct in what I think I should be getting back?
Thanks.
--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com
http://www.benjaminsterling.com