title: Set select options with jQuery
body: <p>How do I set an <code>option</code> value in <code>select</code> list with jQuery? I tried:</p>
  <pre><code>$('#SelectGroup :all').replace(&quot;tmp4&quot;, &quot;abc&quot;);
  </code></pre>
  <p>I mean: Search for <em>tmp4</em> string and replace it with <em>abc</em>. In the list, there are 4 items I don't mind going directly to entrance #4.</p>
  <p>I will extend my question: I want to pass to the function that replaces a value from outside. I tried:</p>
  <pre><code>$('#SelectGroup option').each(function(fieldNum, newVal) { 
        this.text = this.text.replace('tmp4',$(newVal).text());
      });
  });
  </code></pre>
  <p>and I tried:</p>
  <pre><code>$('#SelectGroup option').each(newVal, function() { 
        this.text = this.text.replace('tmp4',newVal);
      });
  });
  </code></pre>
  <p>but here it says it fails! in the first line of <code>.each</code></p>
  <p>Why?</p>
  <p>I don't understand! I pass a value to a function but it loses its value in the function and change</p>
  <pre><code>var newVal=  $(this).val();
  $('#SelectGroup option').each(function(fieldNum, newVal) { 
      alert(&quot;final option text is:&quot; + $(this).text());*/
      alert($(newVal).text());
      this.text = this.text.replace('tmp4',$(newVal).text());  
      });
  });
  </code></pre>
  <p>but newVal is not what I pass to the function - it is what the for each gives it.</p>