我正在使用我在此处找到的模板构建一个 iOS7 WebApp: http://c2prods.com/2013/cloning-the-ui-of-ios-7-with-html-css-and-javascript/
我已经编写了一些 JavaScript/jQuery 淡出图片并淡入工具栏,首先是工具栏。我有一个测试脚本的空白测试页。它工作得很好。然后我将完全相同的代码复制并粘贴到实际页面中,jQuery 似乎永远不会因任何原因加载。它给我一个错误,说以下内容:
未捕获的类型错误:对象 # 没有方法 '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">
非常感谢任何帮助。
提前致谢, 伊曼纽尔
最佳答案
太棒了! scragar 的回答有效!我所要做的就是将 $ 替换为“jQuery”(不带引号)。虽然我不得不用 .delay(3000) 替换 setTimeout 谢谢!
关于javascript - 完全相同的脚本在一页上有效,但在另一页上无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23633646/