jQuery载入屏幕,观看时间最短 [英] jQuery loading screen with minimum viewing time

查看:92
本文介绍了jQuery载入屏幕,观看时间最短的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个正在加载页面的加载屏幕,该页面在加载页面时会显示信息,但是由于互联网速度较快,因此可以在短时间内显示该信息.我想添加一个最短的显示时间!这是我当前的代码

so i have this loading screen that displays information while the page is loading but because of faster internet speeds this can be displayed in a flash.. I would like to add a minimum display time! this is my current code

jQuery(window).load(function() {
    jQuery('.pageLoad').animate({
        opacity: 0
    }, 800, function() {
        jQuery('.pageLoad').css({
            display: 'none'
        });
    });
});

我该怎么做?

推荐答案

您可以将淡出方法放在函数中,并在$(document).ready():xx秒后调用它:

You could put your fade-out method in a function and call that after an xx number of seconds from $(document).ready():

var timeoutID;

jQuery(document).ready(function() {
    // start hiding the message after 2 seconds
    timeoutID = window.setTimeout(hideMessage, 2000);
});

function hideMessage() {
    jQuery('.pageLoad').animate({
        opacity: 0
    }, 800, function() {
        jQuery('.pageLoad').css({
            display: 'none'
        });
    });
}

这篇关于jQuery载入屏幕,观看时间最短的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆