title: fade in then fade out after some time by using css-transitions
body: <p>I'd like to fade in, wait some time, then fade out an element of homepage using jQuery's <code>addClass</code> and <code>removeClass</code></p>
  
  <p>This JS-code fades in the div but doesn't fade it out. I'm using jQuery 2.1.3</p>
  
  <pre><code>if ($("#save-success").hasClass("fadeout")){
       $("#save-success").removeClass("fadeout").addClass("fadein", function() {
           $(this).delay(2000).removeClass("fadein").addClass("fadeout");
      })
  }
  </code></pre>
  
  <p>I've got this CSS:</p>
  
  <pre><code>.fadein, .fadeout {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
  }
  .fadein {
    opacity: 1;
  }
  </code></pre>
  
  <p>this HTML:</p>
  
  <pre><code>&lt;div id="save-success" class="fadeout"&gt;
    Successfully saved
  &lt;/div&gt;
  </code></pre>