Thanks Karl.

Unfortunately I can't guarantee there will be one (or more) tables at 
all.  I'm using dynamic content, so some rows may have one or more sub 
tables, while others will have none...

I *might* be able to rework the code some so there are no nested tables 
(use DIVs instead to get a row effect...).  That would solve my issue 
too.. :)

For now, using the context seems to be working.

Shawn

Karl Swedberg wrote:
> 
> Hi Shawn,
> 
> 
> On Jan 2, 2008, at 5:30 AM, Shawn wrote:
>> I'm working on a table that has nested tables.  My problem is that I
>> need to retrieve all the rows for the main table, but ignore the nested
>> tables.  I know I can do something like this:
>>
>> $("#mytable > tbody > tr");
>>
>>
>> But my table reference is passed into my function(s) as a parameter.  So
>> can I do something like this then?
>>
>> $("tbody > tr", tblRef);
> 
> No. That won't work, as you suggest below.
> 
>> If I'm understanding correctly that would give me all the TRs within the
>> context of my tblRef element.  But wouldn't that also include the nested
>> tables?  Or maybe this
>>
>> $("tbody:first > tr", tblRef);
>>
>> ??
> 
> yes, that should work.
> 
>> I know as a fallback I can do
>> $(tblRef).children("tbody").children("tr");  But that seems inefficient
>> to me...
>>
>> Any tips on doing this?  Thanks in advance.
> 
> Your solution works for me:
> 
> $("tbody:first > tr", tblRef);
> 
> Another option would be this:
> 
> $("> tbody > tr", tblRef);
> 
>  If you're sure there will be one nested table, and you want to select 
> the <tr> only in the outer table, you could also do this:
> 
> $('tr:has(table)', tblRef);
> 
> Cheers,
> 
> --Karl
> _________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
> 

Reply via email to