title: jquery-traversing: select -> option -> text
body: <p>I want to compare a variable with a select -> option -> text selected in order to change the "selected" attrib, here is my code, it works but I think is not the best way to write it, excuse my English, I used google translate for help hehehehe :</p>
  
  <pre><code>var lista = 'example 1'; 
  $("#id option").each(function(){
    if($(this).text() == lista){
      $(this).attr('selected','selected');
    }
  });
  </code></pre>
  
  <p>here's the html:</p>
  
  <pre><code>&lt;select id="id" &gt;
    &lt;option value="0" &gt;example 1&lt;/option&gt;
    &lt;option value="1" &gt;example 2&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>here's a few attempts</p>
  
  <pre><code>$('#id option:eq("'+lista+'")').attr('selected','selected')
  
  $("#id option[text='"+lista+"']").attr('selected','selected')
  </code></pre>