title: Removing a class after a CSS animation has finished - jQuery
body: <p>I have a preloader on my site that has a screen that comes down and then when the page is loaded, the screen goes back up.</p>
  
  <p>This is working on some of my sites pages but on the pages where it loads really quick, the screen comes down but doesn't seem to come back up... </p>
  
  <p>Does anyone know why this might be and how to fix it?</p>
  
  <p>Any help will be appreciated. My code is below.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>jQuery(document).ready(function() {
  
  $('.prepage').addClass("animation");
    $('.prepage').one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend",
                function(event) {
      $(window).on('load', function() {
          $('.prepage').removeClass("animation");
          $('.prepage').addClass("done");
        });
    });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.prepage {
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: pink;
      top: -100%;
      left: 0;
      z-index: 999999999;
      display: flex;
      justify-content: center;
      align-items: center;
      transition: 1s ease-out;
  }
  
  .animation {
      top: 0;
  }
  
  .done {
      top: -100% !important;
      transition: 1s ease-out;
  }
  
  .loader-inside {
      display: inline-block;
      color: white;
      font-weight: bold;
      letter-spacing: 2px;
      font-size: 30px;
      position: relative;
  }
  
  .existing {
      opacity: 0.4;
  }
  
  .headtype {
      position: absolute;
      top: 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="prepage"&gt;&lt;div class="loader-inside"&gt;&lt;p class="existing"&gt;LOADING...&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>