title: select2 - How to change the value to the first option of the list with jQuery?
body: <p>I have a form with a <a href="https://select2.github.io/" rel="nofollow"><code>select2</code></a> dropdown.</p>
  
  <p>The dropdown is in a "modal" window and I want to be able to reset my form when the modal is closed.</p>
  
  <p>Behaviour wanted: When the modal is opened, I want the default value to be the first option in my select.</p>
  
  <pre><code>&lt;select id="mylist"&gt;
      &lt;option value="4"&gt;A&lt;/option&gt;
      &lt;option value="2"&gt;B&lt;/option&gt;
      &lt;option value="1"&gt;C&lt;/option&gt;
      &lt;option value="3"&gt;D&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>In this case, the selected value would be <code>A</code> (value = 4).</p>
  
  <p>Note that these values are populated dynamically and it cannot be hardcoded.</p>
  
  <p>My reset function would be:</p>
  
  <pre><code>function reset() {
      $('#mylist').val( /* Code I'm looking for goes here */ );
  }
  </code></pre>