【发布时间】:2016-04-12 10:06:04
【问题描述】:
我有一个带有闪屏元素的 div。此元素将在页面加载时隐藏。不过,我还想确保启动画面至少显示 x 秒。
我知道这不应该全部格式化为代码,但自动格式化程序让我这样做了。
使用逻辑: 显示启动画面至少 x 秒。 如果到那时页面已加载,则隐藏此 div。
此代码是页面加载后立即隐藏 div 的部分。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
$(document).on("pageload",function(){
$('#splashscreen').hide();
});
</script>
<title>Thomas Shera</title>
</head>
<body>
<div id="splashscreen">
</div>
</body>
</html>
这是我显示初始屏幕 x 秒的部分。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
$(function() {
$("#div2").show().delay(x).hide();
});
</script>
<title>Thomas Shera</title>
</head>
<body>
<div id="splashscreen">
</div>
</body>
</html>
所以基本上我在问,我怎样才能结合这两个 jquery 代码?
编辑:我现在正在尝试此代码,但仍然无法正常工作。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
$(document).on("pageload",function(){
$('#splashscreen').hide();
});
$(function() {
$("splashscreen").show().delay(1000).hide();
});
</script>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Cutive+Mono);
.skills
{
font-family: 'Cultive Mono', monospace;
font-size: 400pt;
}
</style>
<title>Thomas Shera</title>
</head>
<body>
<div id="splashscreen">
<p i="skills">
Javascript Technical writing VBA scripting with Microsoft Office Excel
Entrepreneur
</p>
</div>
</body>
</html>
【问题讨论】: