title: Getting a parent element for a jquery selector
body: <p>I have a table where each row has a CSS id like this:</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr id='1'&gt;...&lt;/tr&gt;
  &lt;tr id='2'&gt;...&lt;/tr&gt;
  &lt;tr id='3'&gt;...&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>In a row, a user can click on a particular element within a cell. I want to find the row that has been clicked on. </p>
  
  <p>So for example:</p>
  
  <pre><code>&lt;tr id='x'&gt;&lt;td&gt;&lt;/td&gt;...&lt;td&gt;&lt;div class='someclass'&gt;&lt;div class='anotherclass'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;...&lt;/tr&gt;
  </code></pre>
  
  <p>In this case, I want to respond when the user clicks on a class='anotherclass' element. I want to get the id of the row containing this clicked element but I don't want to use $(this).parent().parent().parent().... etc. because there are multiple levels of parentage and it gets ugly.</p>
  
  <p>Is there a way to get the row containing this element with using .parent() multiple times?</p>
  
  <p>UPDATE: Thanks everyone. That is perfect.</p>