Link to home
Start Free TrialLog in
Avatar of Sailing_12
Sailing_12

asked on

Syntax to combine parent() and next() to traverse table rows

What is the syntax to use jQuery parent() and next() functions together to traverse table rows.

I have a table with an image in the first celll of all of the odd rows which I want to use as a trigger to expand the corresponding next row. So from the image element, I guess I want to traverse up two parents (td and tr) and then get the next tr in the table.
ASKER CERTIFIED SOLUTION
Avatar of dirknibleck
dirknibleck

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sailing_12
Sailing_12

ASKER

Thanks. I just figured that out here but was wondering if there was a better way to code it.
The only other suggestion I can think of would be:

$(this).parents("tr").next()

(note the s on parents)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sailing_12,

Note, that the method parent is different than parents (with s). parent will only return the first ancestor of an element, but parents will return all ancestor without the root element.
Great thanks.
Thanks.