开发者

jQuery Fade In and Out

开发者 https://www.devze.com 2023-02-03 15:50 出处:网络
How do I get jQuery to fade out the $(\"#recentTrack\"), replace it\'s contents, and then fade it in again? The current code fades it out and keeps it hidden, rather than fading it in again:

How do I get jQuery to fade out the $("#recentTrack"), replace it's contents, and then fade it in again? The current code fades it out and keeps it hidden, rather than fading it in again:

    setInterval(
    function ()
    {
            $.getJS开发者_开发知识库ON('cache/lastfmCache.json', function(data){
            var x = data.recenttracks.track[0].artist["#text"];
            var y = $("#recentTrack").html();
            if(x != y) {
                $("#recentTrack").fadeOut('slow').html(x).fadeIn('slow)';
             }      
        $.get('update.php');    
    });
    }, 15000);


Just change $("#recentTrack").fadeOut('slow').html(x).fadeIn('slow)';

into:

$("#recentTrack").fadeOut('slow', function(){
  $(this).html(x).fadeIn("slow");
});

This way you wait for the event to complete.

0

精彩评论

暂无评论...
验证码 换一张
取 消