[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-10 Thread pantagruel
 rowsBefore = row.rowIndex; Ok, but jQuery(#activator + input).parent().parent(); selects the row, but when I try to get rowIndex of that selected row I get undefined back. var trow = jQuery(#activator + input).parent().parent(); alert(trow.attr(class)); // the class of my row

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-10 Thread James
Try: alert( trow.get(0).rowIndex ); On Feb 10, 8:19 am, pantagruel rasmussen.br...@gmail.com wrote:  rowsBefore = row.rowIndex; Ok, but jQuery(#activator + input).parent().parent(); selects the row, but when I try to get rowIndex of that selected row I get undefined back. var trow =

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-10 Thread mkmanning
rowIndex is a DOM property, so you'd have to use alert(trow [0].rowIndex); On Feb 10, 10:19 am, pantagruel rasmussen.br...@gmail.com wrote:  rowsBefore = row.rowIndex; Ok, but jQuery(#activator + input).parent().parent(); selects the row, but when I try to get rowIndex of that selected row

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-09 Thread Karl Swedberg
Oh yeah! Good point, Rob. I always forget these DOM properties. Thanks for the reminder. :) --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Feb 9, 2009, at 2:37 AM, RobG wrote: On Feb 9, 4:23 am, pantagruel rasmussen.br...@gmail.com wrote: Hi, I am

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-09 Thread Nivash Ramachandran
Great discussion. Thanks for all. -- Nivash Ramachandran On Mon, Feb 9, 2009 at 7:19 PM, Karl Swedberg k...@englishrules.com wrote: Oh yeah! Good point, Rob. I always forget these DOM properties. Thanks for the reminder. :) --Karl Karl Swedberg www.englishrules.com

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-08 Thread James
Assuming row means the number of tr, and your tables looks like: table trtddata/td/tr trtddata/td/tr trtddata/td/tr trtddata/td/tr trtddata/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,

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-08 Thread James
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      trtddata/td/tr      trtddata/td/tr      trtddata/td/tr      

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-08 Thread James
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

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-08 Thread Ricardo Tomasi
you should be looking at http://docs.jquery.com/Traversing var currentRow = $('table tr').eq(7); var howManyBefore = currentRow.prevAll('tr').length; cheers, - ricardo On Feb 8, 3:23 pm, pantagruel rasmussen.br...@gmail.com wrote: Hi, I am selecting the row of a table. I would like to be

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-08 Thread Karl Swedberg
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:

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-08 Thread Karl Swedberg
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,

[jQuery] Re: selector to return the number of rows in a table before the row I just selected

2009-02-08 Thread RobG
On Feb 9, 4: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. Not necessary - table rows