Jump to content

jQuery selector help


skaterdav85
 Share

Recommended Posts

So I have a table with several rows generated dynamically like this:

<tr>	<td>text 2</td>	<td><img src='#' /></td></tr>

When the image is clicked, it runs a function and performs a fade on the entire row like this:

jQuery(this).parent().parent().fadeTo(700, 0.3);

I was wondering if there is a more efficient way of getting the <tr> element through the parent/child relationship. This worked, but i dont like how i used parent() twice to go up 2 levels.

Link to comment
Share on other sites

You can try using jQuery(this).prev('tr').fadeTo(700, 0.3);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...