完全相同的脚本工作在一页,但不是另一个

Exact Same Script Works On One Page But Not Another

本文关键字:一页 另一个 工作 脚本      更新时间:2023-09-26

我正在用我在这里找到的模板构建一个iOS7 WebApp:http://c2prods.com/2013/cloning-the-ui-of-ios-7-with-html-css-and-javascript/

我已经写了一些JavaScript/jQuery淡入淡出图片和淡入工具栏,工具栏首先。我有一个空白的测试页,我测试的脚本。效果很好。然后我复制并粘贴完全相同的代码到实际页面和jQuery似乎从来没有加载的原因。它给出如下错误:

未捕获的TypeError: object#没有方法'fadeOut'

衰落应该在3秒后发生。这个想法是,这是一个闪屏。

这是我的JS/jQuery:
$(document).ready(function() {
fadeAwaySplash();
navFadeIn();
//Insert More Functions Here
});
function fadeAwaySplash() {
    //setTimeout(function() {
    $("#splash-screen").fadeOut();
    //}, 3000);
}
function navFadeIn(){
    setTimeout(function() {
    $("nav").fadeIn();
    }, 3000);
}
这是我的CSS:
nav {
position: fixed;
bottom: 0;
width: 100%;
height: 49px;
text-align: center;
background-color: rgba(248, 248, 248, 0.9);
background-image: linear-gradient(180deg, rgb(200, 199, 204), rgb(200, 199, 204) 50%, transparent 50%);
background-size: 100% 1px;
background-repeat: no-repeat;
background-position: top center;
z-index: 100;
display: none;
}
#splash-screen {
position: absolute;
z-index: 999999;
width: 100%;
height: 100%;
min-width: 100%;
min-height: 100%;
max-width: 100%;
max-height: 100%;
}
这是我的HTML:
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<img src="/img/ipadSplash.png" id="splash-screen">

感谢您的帮助。

提前感谢,伊曼纽尔

太棒了!斯克拉格的回答起作用了!我所要做的就是将$替换为"jQuery"(不带引号)。虽然我不得不用。delay(3000)代替setTimeout,谢谢!