oh ok... i guess, that is a good solution
overall. I would use that. I don't know what other prefer though.
But, i wouldn't give ids to each and every cell in the table just for the
purpose of selection. it increases markup size.

-GTG



On 8/3/07, Matt Penner <[EMAIL PROTECTED]> wrote:
>
> You're right GTG.
>
> I found this out quickly after my post.  I'm using the following:
> $('tr:eq(2) td:eq(3)')
> which seems to get exactly the one cell I'm looking for.
>
> Just for sake of argument this is a very simple example.  I use variables
> in my code and I have only one table on the page.  If I had multiple tables
> this would indeed return multiple elements unless I selected the individual
> table as well.  At least this is my understanding.
>
> Matt
>
> ________________________________________
> From: jquery-en@googlegroups.com [mailto:jquery-en@googlegroups.com ] On
> Behalf Of Ganeshji Marwaha
> Sent: Friday, August 03, 2007 2:54 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: Best way to select a cell in a table?
>
> I don't think ur selector is right for selecting the 2nd row, 3rd column.
> It most probably is returning you more elements depending on the number of
> rows u have.
> Eg: if you have 3 rows in your table, then it should return, 1 tr and 3
> td's each representing the 3rd column in every row.
>
> I would use $("td:eq(2)", $("tr:eq(1)"))
>
> -GTG
> On 8/3/07, Matt Penner <[EMAIL PROTECTED] > wrote:
> I have a table that represents a matrix with various columns and rows.  I
> use AJAX/JSON to populate the various cells with data.  Not every cell will
> contain an item of data and some may have more than one item.
>
> What's the best way to select a specific cell of the table?
>
> If I wanted the 2nd row 3rd cell the following works:
> $("tr:eq(1), td:eq(2)")
>
> This is a rather simplistic example but is this better than, say, giving
> every cell its own id or is there a completely different method that others
> prefer?
>
> Thanks,
> Matt Penner
>
>

Reply via email to