首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Timed FadeOut不工作

Timed FadeOut不工作
EN

Stack Overflow用户
提问于 2015-04-13 08:20:30
回答 2查看 32关注 0票数 0

我一直想在一段时间后使图像淡出。我在Stackoverflow中找到了相同的主题,但我的主题不起作用。

如果有人能快速看一眼我的代码,我将非常感激?

我想淡入的图像是:

我的代码:

代码语言:javascript
复制
<!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>
EN

回答 2

Stack Overflow用户

发布于 2015-04-13 08:39:03

您是否为页面提供了指向jQuery代码的链接。看起来您没有,所以计算机无法理解$(window).load()事件或$("#myImage").fadeOut()方法。要解决这个问题,只需将这行代码添加到页面的标题部分-

代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>

如果您更喜欢使用更高版本的jQuery,可以在jQuery网站上查看更多信息。如果此方法仍然不起作用,请尝试用$("#myImage").fadeTo("slow",0)替换$("myImage").fadeOut()

希望这能有所帮助。

票数 1
EN

Stack Overflow用户

发布于 2015-04-13 09:03:37

试一试

代码语言:javascript
复制
$(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
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29596197

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档