jQuery fadeIn 持续时间没有效果

标签 jquery fadein

我正在尝试在我的网络应用程序中使用 jQuery fadIn 函数,但持续时间/速度参数没有任何效果。 HTML 代码如下:

<!DOCTYPE html>
<html>
<head>
    <title>Web App Test Bench</title>
    <meta name="viewport" content="user-scalable=yes,width=device-width" />
    <meta charset="ISO-8859-1"/>
    <link rel="icon" type="image/png" href="mj_logo.png" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0 /jquery.mobile-1.1.0.min.css" />


    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>


<script type="text/javascript" src="test.js"></script>
<body>
    <section id="page1" data-role="page">

    <div data-role="content" class="content">

    <img id="logo" src="welcomeLogo.jpg" alt="Welcome Logo"/>

    </div>

</section>

</body>
</html>

JavaScript 是:

$(document).ready(function()
{
    $("#logo").hide().fadeIn("8000",function()
    {
        console.log("The animation is done");
    }
    ).fadeOut("8000");


})

无论我选择哪个值,无论大小,动画都会在一瞬间完成。对于可能出现的问题有什么建议吗?

最佳答案

您需要将速度作为整数而不是字符串值传递,从而使您的代码:

$(document).ready(function()
{
    $("#logo").hide().fadeIn(8000,function()
    {
        console.log("The animation is done");
    }
    ).fadeOut(8000);   
})

如果您确实想使用字符串值,则可以使用“fast”和“slow”分别表示 200 毫秒和 600 毫秒的持续时间。

关于jQuery fadeIn 持续时间没有效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11614487/

相关文章:

Javascript setTimeout 运行两次?

javascript - jQuery 停止淡出/淡入循环

jQuery 和 Colorbox : How to automatically set the height and width of an iframe colorbox

jquery - 带有流畅水平子菜单的垂直导航

javascript - 如何使 div 在其中加载 PDF 文档时不滚动

jquery - Chrome 淡入滚动条问题

javascript - 以不同的随机时间效果淡入段落的每个单词

jquery - 使用 jQuery 禁用和启用下拉选项

javascript - 单击 anchor 标记时淡入和淡出

javascript - jQuery FadeIn 和 FadeOut 导致闪烁?