title: How to create options of a select element dynamically using jquery?
body: <p>I need to create options of a select element dynamically via an ajax call. The number of options and their content will vary. This is how it looks prior to the ajax call:</p>
  
  <pre><code> &lt;select name="groupid" style="width:100%;"&gt;
  &lt;option value="0" selected&gt;(Please select an option)&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Here is one of my attempts to create an option element with a dummy value:</p>
  
  <pre><code>$("&lt;option&gt;&lt;/option&gt;", {value: "999"}).appendTo('.select-group');
  </code></pre>
  
  <p>But it adds it outside of select. I also don't know how to set the text within .</p>
  
  <p>Any ideas? I've seen some questions about populating existing select forms with a static number of existing options but not one like this. </p>
  
  <p>Thanks.</p>