title: jQuery how to undo a select change
body: <p>I have a select box, and I'd like to add a confirm before changing it to a specific option. Example:</p>
  
  <pre><code>&lt;select name="select">
      &lt;option value="foo" selected="selected">foo&lt;/option>
      &lt;option value="bar">bar&lt;/option>
  &lt;/select>​​​​​​​​​​​​​​​​​​</code></pre>
  
  <pre><code>$('select').change(function() {
      var selected = $(this).val();
  
      if (selected == 'bar') {
          if (!confirm('Are you sure?')) {
              // set back to previously selected option
          }
      }
  });</code></pre>
  
  <p>I'm thinking about adding a hidden input field and update its value every time the select is changed. That way I can retrieve the previous value in the <code>change</code> function. <a href="http://jsfiddle.net/eUM4D/" rel="noreferrer">Example</a>:</p>
  
  <pre><code>&lt;input type="hidden" name="current" value="foo" /></code></pre>
  
  <pre><code>$('select').change(function() {
      var selected = $(this).val();
      var current = $('input[name=current]').val();
  
      if (selected == 'bar') {
          if (!confirm('Are you sure?')) {
              $(this).val(current);
              return false;
          }
      }
  
      $('input[name=current]').val(selected);
  });</code></pre>
  
  <p>Is there an easier/better way to accomplish this?</p>