jQuery fadeIn() 不淡入

发布于 2024-08-24 01:50:20 字数 348 浏览 4 评论 0原文

这个已经被难住了。我正在向元素添加一些 HTML,然后想要将其淡入。但是,在实现时,它不会淡入。它只是立即“捕捉”。语法/顺序看起来正确。任何人都认为我的逻辑有问题:

$('span.mySpan')
    // fade out the empty span so it's hidden
    .fadeOut('fast',function(){
        $(this)
            .html($restoreLink) // add the HTML to the hidden span
            .fadeIn('slow') // now fade it in 
    })

This one has be stumped. I'm adding some HTML to a element and then want to fade it in. However, when implemented, it doesn't fade in. It just 'snaps' in immediately. The syntax/order looks right. Anyone see anything wrong with my logic:

$('span.mySpan')
    // fade out the empty span so it's hidden
    .fadeOut('fast',function(){
        $(this)
            .html($restoreLink) // add the HTML to the hidden span
            .fadeIn('slow') // now fade it in 
    })

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鲜血染红嫁衣 2024-08-31 01:50:20

它确实有效,这就是我所使用的:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script>
        $(document).ready(function() {
                $('span.mySpan')
    // fade out the empty span so it's hidden
    .fadeOut('fast',function(){
        $(this)
            .html('<strong>testing</strong>') // add the HTML to the hidden span
            .fadeIn(2000) // now fade it in
    })

        });
</script>
</head>
<body>
<span class="mySpan">Hello</span>

</body>
</html>

它只是淡入得非常快。将计时器设置为... 5000 毫秒,看看我的意思。

It does work here's what I used:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script>
        $(document).ready(function() {
                $('span.mySpan')
    // fade out the empty span so it's hidden
    .fadeOut('fast',function(){
        $(this)
            .html('<strong>testing</strong>') // add the HTML to the hidden span
            .fadeIn(2000) // now fade it in
    })

        });
</script>
</head>
<body>
<span class="mySpan">Hello</span>

</body>
</html>

It just fades in really fast. Set the timer to say... 5000 milliseconds to see what I mean.

风启觞 2024-08-31 01:50:20

您需要在 fadeIn 行末尾和函数末尾添加分号吗? --> ;

$('span.mySpan')
    // fade out the empty span so it's hidden
    .fadeOut('fast',function(){
        $(this)
            .html($restoreLink) // add the HTML to the hidden span
            .fadeIn('slow'); // added ;
    }); // added ;

Do you need the semicolon at the end of fadeIn line and at the end of the function? --> ;

$('span.mySpan')
    // fade out the empty span so it's hidden
    .fadeOut('fast',function(){
        $(this)
            .html($restoreLink) // add the HTML to the hidden span
            .fadeIn('slow'); // added ;
    }); // added ;
荆棘i 2024-08-31 01:50:20

您使用的是 Internet Explorer 8 吗?我相信 IE8 中 JQuery 的不透明度操作无法正常工作。

Are you using Internet explorer 8? I believe that opacity manipulations with JQuery in IE8 do not work properly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文