alpha
alpha

Reputation: 501

Jquery selecting values from on table while in another table

I have two tables that are dynamically created (as a set). From a button click in a cell of the second(bottom) table, I need to traverse back up to a previous table to get a value.

This line gives me table Id in which the button is in.
1)Is this the right syntax? I don't want to accidently get another table below it (because there could be another set of two tables below this set)

$(this).closest('table')[0].id

Now I need a way to get to the table above it. And then in that table, I need to get the the last row.

Thanks.

Upvotes: 0

Views: 26

Answers (1)

one stevy boi
one stevy boi

Reputation: 576

assuming your table is directly above $(this).closest('table')[0], then you can access it with $(this).closest('table')[0].prev()

Upvotes: 1

Related Questions