title: jquery select list option focus
body: <p>I am trying to do a month year drop down that takes the HTML and removes previous months if the current year is selected. All works ok but it always sets the month option focus to the last one in the object, have tried focus, selected with no joy.</p>
  
  <p><a href="http://jsfiddle.net/FneGp/" rel="nofollow">http://jsfiddle.net/FneGp/</a> </p>
  
  <pre><code>var selectList = $("select#months");
      var selectListOptions = $("select#months option");
  
      var d = new Date(),
          n = d.getMonth(),
          y = d.getFullYear();
      $("select#years").on("change", function (){
          if ($(this).val() == y) {
              $("select#months").children("option").each(function () {
                  if ($(this).val() &lt;= n) {
                      $(this).remove();
                  }
              });
  
          }
          else {
              selectListOptions.appendTo(selectList);
          }
      });
  </code></pre>
  
  <p>I have set up a fiddle to show the problem.</p>
  
  <p>Any help gratefully appreciated</p>
  
  <p>Thanks in advance</p>
  
  <p>Richard</p>