title: How to wait until jQuery effects have finished?
body: <p>How can I wait until an animation is finished in jQuery?</p>
  
  <pre class="lang-js prettyprint-override"><code>function foo() {
    $("#element").fadeOut();
  }
  </code></pre>
  
  <p>I need the <code>.fadeOut()</code> to complete before <code>foo()</code> returns because the calling code expects the DOM to be free of <code>#element</code>.</p>