title: Traversing backwards using jquery
body: <p>I have a code like below</p>
  
  <p>If I click the "finallink" class, i want to select or display  all previous elements that matches "level_" class until the "parent" class. There are so many "level" classes like "level_1, level_2... level_n.</p>
  
  <p>​</p>
  
  <pre><code>&lt;div class="parent"&gt;
      &lt;a href="#" class="level_0"&gt;level 0 text&lt;/a&gt;
  
      &lt;div class="someclass"&gt;1&lt;/div&gt;
      &lt;div class="someclass"&gt;2&lt;/div&gt;
      &lt;div class="someclass"&gt;3&lt;/div&gt;
      &lt;div class="someclass"&gt;4&lt;/div&gt;
  
      &lt;h1 class="level_1"&gt;level 1 text&lt;/h1&gt;
  
      &lt;div class="someclass"&gt;1&lt;/div&gt;
      &lt;div class="someclass"&gt;2&lt;/div&gt;
      &lt;div class="someclass"&gt;3&lt;/div&gt;
      &lt;div class="someclass"&gt;4&lt;/div&gt;
  
      &lt;h2 class="level_2"&gt;level 2 text&lt;/h2&gt;
  
      &lt;a href="#" class="finallink"&gt;link&lt;/a&gt;
  &lt;/div&gt;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
  </code></pre>
  
  <p>I tried something like this</p>
  
  <pre><code>$(".finallink").closest("h3").prevAll("level_1").css("background-color","yellow");
  </code></pre>
  
  <p>How Do I get all "level_" values. Example code <a href="http://jsfiddle.net/xpuCb/" rel="nofollow">jsfiddle</a></p>