代码之家  ›  专栏  ›  技术社区  ›  DA.

jquery fadein()不淡入

  •  0
  • DA.  · 技术社区  · 16 年前

    这个已经被难住了。我正在向元素中添加一些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 
        })
    
    3 回复  |  直到 16 年前
        1
  •  2
  •   Mike Thomsen    16 年前

    我用的是:

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

        2
  •  0
  •   Matt Crest    16 年前

    您需要在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 ;
    
        3
  •  0
  •   neuroguy123    16 年前

    您正在使用Internet Explorer 8吗?我认为ie8中jquery的不透明操作不能正常工作。