jquery fade in callback not waiting

前端 未结 4 581
心在旅途
心在旅途 2021-01-20 06:51

im trying to make a div fade out and then have a second div fade in in its place but the callback for the second div to fade is doesn\'t seem to wait for the first to finish

相关标签:
4条回答
  • 2021-01-20 07:31

    you should try to alter the times, they are easing at the same speed:

    $("#story2").fadeIn("1000", function(){ $("#story1").fadeOut("300"); });
    

    try that :)

    0 讨论(0)
  • 2021-01-20 07:33

    You're fading IN the new div before fading OUT the other div. That creates a cross fade effect so that's why you're seeing it. Perhaps what you mean to do is:

    $("#story1").fadeOut("300", function () {
        $("#story2").fadeIn("300");
    });
    

    Fade out the current one before you fade in the next one. Then, you won't see them both on screen at the same time (e.g. no crossfade).

    0 讨论(0)
  • 2021-01-20 07:50

    Check this out with example jsfiddle

    $("#story1").fadeOut("300").delay(600,function(){$("#story2").fadeIn("300");})
    
    0 讨论(0)
  • 2021-01-20 07:55

    You could try:
    $("#story1").delay(500).fadeOut("300");

    0 讨论(0)
提交回复
热议问题