title: jQuery each loop - using variables
body: <p>I have a list of products. Each product has a title and a review link. Currently the titles link directly to the individual product page, and the review links go elsewhere. </p>
  
  <p>I'd like to use a jquery each loop to cycle through each li, take the href from the title (the first link), and apply it to the review link (the second link), so they both point to the product page.</p>
  
  <p>Simplified code would be as follows:</p>
  
  <pre><code>&lt;ul&gt;
     &lt;li&gt;&lt;a href="product1.html"&gt;Product 1&lt;/a&gt;&lt;a href="review1.html"&gt;Review 1&lt;/a&gt;&lt;/li&gt;
     &lt;li&gt;&lt;a href="product2.html"&gt;Product 2&lt;/a&gt;&lt;a href="review2.html"&gt;Review 2&lt;/a&gt;&lt;/li&gt;
     &lt;li&gt;&lt;a href="product3.html"&gt;Product 3&lt;/a&gt;&lt;a href="review3.html"&gt;Review 3&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I thought it would be something like the following:</p>
  
  <pre><code>$("li").each(function(){
     var link = $("a:eq(0)").attr('href');
     $("a:eq(1)").attr("href", link);
  });
  </code></pre>
  
  <p>But it always uses the same variable "link".</p>
  
  <p>Can someone help me out?</p>