我的问题很简单(我想,但我找不到任何参考,谁想放慢他们的网站,对吗?)也许听起来很荒谬,但是我想要做的是在我的网站主页/索引的页面上设置一个大屏幕。我所做的就是在我的页面顶部添加一个简单的div,然后在加载页面时使用javascript来隐藏它。
$(window).bind("load", function () {
// Remove splash screen after load
$('.splash').css('display', 'none')
})但我的问题是,我的主索引加载得太快(因为它只是纯文本/html),因此启动屏幕只显示.5秒。我想在删除之前至少添加2-3秒,我假设我只需要在我的$(window).bind中添加一两行代码,在执行$('.splash').css('display', 'none')之前暂停几秒钟,但是我不知道该做什么或如何做,请帮助!谢谢!
发布于 2015-06-03 21:50:12
可以使用setTimeout()来延迟Javascript中的内容,如下所示:
$(window).bind("load", function () {
var delay = 5000;
setTimeout(function () {
$('.splash').css('display', 'none');
}, delay);
});发布于 2015-06-03 21:52:14
超时有效。
$(window).bind("load", function () { // Remove splash screen after load and 3 seconds setTimeout(function() { $('.splash').css('display', 'none') }, 3000); });
https://stackoverflow.com/questions/30631362
复制相似问题