Karl,
That is what I expected get too, just needed to clarify.

If you just want to select table cells, why not do $('td:contains(Cell)') ?
>

I am doing an article on selectors and selector speeds and was experimenting
on what approach is faster[1] and when I got to this selector, I would have
expected the BODY and HTML be selected also, but since it did not, I started
to second guess myself.

I have a test page up at
http://benjaminsterling.com/articles/jQuery-%20Select%20what%20you%20want%20-%20part%201.htm

and if you hit the "Test 10 toggle" button, you will see that only the table
elements are getting the background color of #FF0 as well as the DIV that
the TABLE is wrapped in, leaving the  BODY, and HTML tags alone.  So would
you say this is a bug or something we should expect?

Thanks.

On 11/24/07, Karl Swedberg <[EMAIL PROTECTED]> wrote:
>
> 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
>
>
>


-- 
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com
http://www.benjaminsterling.com

Reply via email to