title: Reverting jquery animations back to original css states
body: <p>I've got a page of elements, each of which, depending on user interaction, may be animated away by the given function:</p>
  
  <pre><code>function slideAndFade(id){
      $(id).animate({opacity: 'toggle', width: 'toggle'}, 500);
  }
  </code></pre>
  
  <p>I want to create a reset function that brings all the elements back onto the page.  Running all the elements through the toggle function above won't work, because currently hidden elements will be shown, and currently shown elements will be hidden.  </p>
  
  <p>Essentially looking for way to revert all elements to their original css states, regardless of whether they've been acted upon by jquery animation.</p>
  
  <p>Thanks- </p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Just realized all I need to do is replace 'toggle' with 'show':</p>
  
  <pre><code>function revertSlideAndFade(id){
      $(id).animate({opacity: 'show', width: 'show'}, 500);
  }
  </code></pre>
  
  <p>Calling this on any element will ensure the element is reverted back to visible in this case. However, see <a href="https://stackoverflow.com/questions/3619747/reverting-jquery-animations-back-to-original-states/3619827#3619827">Nick's answer</a> below for a more generally applicable approach. </p>