title: How do you go backwards through a chain using Jquery?
body: <p>I thought there was something in jquery that allowed you go backward through a chain.</p>
  
  <p>I want to do this:</p>
  
  <pre><code>var a = $(this).parent().addClass('test').goBackToParent().children('selectorHere').text()
  </code></pre>
  
  <p>I want to get the parent of the object that I have and add a class name to it. Once I do that I want to go through its children and find a child that matches my selector and get its text.</p>
  
  <p>Can I do this, or do I have to do this instead:</p>
  
  <pre><code>$(this).parent().addClass('test');
  var a = $(this).parent().children('selectorHere').text()
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>I am using "end" now but it does not work I made an example that you can try <a href="http://jsbin.com/uzocu4/2" rel="nofollow noreferrer"> here </a></p>
  
  <pre><code>&lt;table&gt;
      &lt;th&gt;
          &lt;tr&gt;one&lt;/tr&gt;
          &lt;tr&gt;two&lt;/tr&gt;
      &lt;/th&gt;
      &lt;tr&gt;
          &lt;td id="test"&gt;&lt;a href="#"&gt;&lt;img src="http://ais.web.cern.ch/ais/apps/hrt/SMT%20v2/Images/btnbar_edit.png" /&gt;&lt;/a&gt;&lt;/td&gt;
          &lt;td class="selectMe"&gt;1&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  
  $(function() {
      $('#test').click(function() {
          // does not work
          var a = $(this).parent().addClass('afb')
                     .end().children('.selectMe').text();
  
          // works
          var b = $(this).parent().children('.selectMe').text();
  
          alert(a + ' -should have value');
          alert(b + ' -works');
  
          return false;
      });
  });
  </code></pre>