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 
    })
4

3 回答 3

2

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

<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 毫秒,看看我的意思。

于 2010-03-04T20:23:08.537 回答
0

您是否需要在 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 ;
于 2010-03-04T20:13:58.050 回答
0

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

于 2010-03-04T20:15:31.563 回答