Search code examples
javascriptjqueryhtmlcsspreloader

How to set fixed time for preloader


I want to set a fixed time in my preloader for my website. Because after preloading image I can't see any animation in my home section.

 $(window).load(function() { 
            $('#preloader').fadeOut(); 
            $('.preloader_img').delay(150).fadeOut('slow');     
});

Thanks


Solution

  • Surround the code with a setTimeout() function, like so:

    setTimeout(function(){        
        $('#preloader').fadeOut();
        $('.preloader_img').delay(150).fadeOut('slow'); 
    }, 10000);
    

    Change 10000 with whatever amount you want in milliseconds and remember 1000 milliseconds equals 1 second.