title: jQuery create select options using loop
body: <p>Im trying to create select box using jquery but the links populates randomly so I need to loops thru links and grab it to make select box, here is my code any idea how to use a short hand/loop? Thanks</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;p&gt;
      &lt;a href="#"&gt;option1&lt;/a&gt;
      &lt;a href="#"&gt;option2&lt;/a&gt;
      &lt;a href="#"&gt;option3&lt;/a&gt;
  &lt;/p&gt;
  
  &lt;select  id="select"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>$.fn.populate = function() {
      var option1 = $('p a:eq(0)').text();
      var option2 = $('p a:eq(1)').text();
      var option3 = $('p a:eq(2)').text();
    $(this)
      .append('&lt;option value=""&gt;' + option1 + '&lt;/option&gt;')
      .append('&lt;option value=""&gt;' + option2 + '&lt;/option&gt;')
      .append('&lt;option value=""&gt;' + option3 + '&lt;/option&gt;')
  }
  
  $('#select').populate();
  </code></pre>
  
  <p><a href="http://jsfiddle.net/QgCqE/" rel="noreferrer">Fiddle</a></p>