Oops. Sorry, I didn't see Ricardo's reply before posting. In any case, there's no need to filter the .prevAll() with 'tr', since no other element is allowed as a sibling of a tr.

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Feb 8, 2009, at 6:06 PM, Karl Swedberg wrote:

You could use prevAll()

$('#myrow').prevAll().length;

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Feb 8, 2009, at 2:30 PM, James wrote:


I did a search but I could only find a selector that selected "after"
something:
http://docs.jquery.com/Selectors/siblings#prevsiblings
can help.

Maybe you can get the total rows count, subtract from the count from
prev ~ siblings (and probably subtract 1 also).
I hope that helps somewhat.

On Feb 8, 9:24 am, James <james.gp....@gmail.com> wrote:
Oops, I misread. You wanted the count "before" the one you selected.
Please disregard my response!

On Feb 8, 9:22 am, James <james.gp....@gmail.com> wrote:

Assuming "row" means the number of <tr>,
and your tables looks like:
<table>
     <tr><td>data</td></tr>
     <tr><td>data</td></tr>
     <tr><td>data</td></tr>
     <tr><td>data</td></tr>
     <tr><td>data</td></tr>
</table>

 you can do something like:
var count = $("table tr").length;

http://docs.jquery.com/Core/length

On Feb 8, 8:23 am, pantagruel <rasmussen.br...@gmail.com> wrote:

Hi,

I am selecting the row of a table. I would like to be able to count how many rows there are in the table before the row I just selected. i
suppose there is a jQuery selector that will do this.

Thanks


Reply via email to