views:

206

answers:

3

I am a beginner in jQuery. I have a table with multiple rows, how do I select next row or previous row after selecting a particlar row?

+1  A: 

For the next row (assuming myRow is your selected row element):

$(myRow).next();

I'd recommend using the very powerful selector syntax, instead of selecting previous and next elements based on currently selected element instances, however:

http://docs.jquery.com/Selectors

Gurdas Nijor
A: 
$(this).next();

or

$(this).prev();
Jakobud
Preetham
A: 

I am selecting a row using "onclick" event and changing its class name to "xyz". now I want the next row to the row with classname "xyz".

I have used $(".xyz").next() & $(".xyz").prev(), but the result set is empty.

Preetham
Preetham, once you've asked the question, you should comment on other replies instead of answering your own question.
Gurdas Nijor
Are you setting the "onclick" event for the button within the $(document).ready(); handler?
Gurdas Nijor