我一直想在一段时间后使图像淡出。我在Stackoverflow中找到了相同的主题,但我的主题不起作用。
如果有人能快速看一眼我的代码,我将非常感激?
我想淡入的图像是:
我的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>ACC BIC - Business Industry Description</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="images/favicon.png">
</head>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div class="container">
<div class="row">
<div class="twelve columns">
<!-- Bottom bar navigation -->
<div class="btn btn-two">
<span class="btn-two--link"><a href="#.html"></a></span>
<span class="btn-three--link"><a href="selection-5.html"></a></span>
<span class="btn-four--link"><a href="index.html"></a></span>
<img id="myImage" class="email-sent-img" src="images/email-link-sent.png" alt="">
<script>
$(window).load(function(){
setTimeout(function(){ $('#myImage').fadeOut() }, 5000);
});
</script>
</div>
<!-- Background image -->
<img class="proto-img" src="images/cards-view-selected.png" alt="">
</div>
</div>
</div>
<!-- End Document
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
</body>
</html>发布于 2015-04-13 08:39:03
您是否为页面提供了指向jQuery代码的链接。看起来您没有,所以计算机无法理解$(window).load()事件或$("#myImage").fadeOut()方法。要解决这个问题,只需将这行代码添加到页面的标题部分-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>如果您更喜欢使用更高版本的jQuery,可以在jQuery网站上查看更多信息。如果此方法仍然不起作用,请尝试用$("#myImage").fadeTo("slow",0)替换$("myImage").fadeOut()
希望这能有所帮助。
发布于 2015-04-13 09:03:37
试一试
$(window).on('load', function () {
setTimeout(function () {
$("#image").fadeOut("slow", function () { // Instead of Slow you could add 5000 (5s)
// fade out complete if you need to run another event
});
}, 5000); // fade out starts after 5s
});https://stackoverflow.com/questions/29596197
复制相似问题