title: Jquery find an anchor link with the href of another item's id
body: <p>Trying to find an element with jquery and have hit a roadblock.</p>
  
  <p>I have a variable with another elements id stored in it. I am trying to find the corresponding anchor link with that stored variable as it's href. Then get the anchor link(href) directly before that anchor.</p>
  
  <p>So basically finding the list item anchor link previous to the list item anchor link with the id of the displayed div</p>
  
  <p>.html</p>
  
  <pre><code>&lt;li&gt;&lt;a href="#example" class="links"&gt;example&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#example1" class="links"&gt;example&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#example2" class="links"&gt;example&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#example3" class="links"&gt;example&lt;/a&gt;&lt;/li&gt;
  
  &lt;div id="example" class="divs"&gt; random stuff &lt;/div&gt;
  &lt;div id="example1" class="divs open"&gt; random stuff &lt;/div&gt;
  &lt;div id="example2" class="divs"&gt; random stuff &lt;/div&gt;
  &lt;div id="example3" class="divs"&gt; random stuff &lt;/div&gt;
  </code></pre>
  
  <p>.js </p>
  
  <pre><code>$('.previous').click(function(e) {
      e.preventDefault();
      var exampleId = $('.divs.open').attr('id');
      var anchorPrev = $('.links').find('href');
  });
  </code></pre>