poner en cola los efectos jquery asíncronos en diferentes divs con una llamada de función de sincronización

I want to fade out div1. Then fade in div2. Then execute the doStuffAtTheEnd function.

I thought when each effect takes a callback everything is synchron. But I never see the fade in of div2. Its just visible immediatelly without fade in effect.

¿Por qué es eso?

$('#div1').fadeOut(1000, function () {
    $('#div2').fadeIn(1000), function(){           
            doStuffAtTheEnd();
        }); 
});

preguntado el 17 de mayo de 13 a las 07:05

asegurarse div2 is hidden in default.. -

@bipen and where should I call the .show() then? -

1 Respuestas

you have incorrect closing bracket )

prueba este

$('#div1').fadeOut(1000, function () {
   $('#div2').fadeIn(1000, function(){  
                   //----^----here         
        doStuffAtTheEnd();
    }); 
});

y asegúrate div2 is hidden in default.

actualizado

add display:none in your css for the div2 or hide it it document.ready function $('#div2').hide()... created this example fiddle (assuming this is what you want)...

violín aquí

contestado el 17 de mayo de 13 a las 08:05

nah sorry thats just a typo not the original problem. - Elisabeth

@Elisa updated please check.. fadeIn by default shows the hidden elements - bipen

the trick was the .hide() initially for the div I want to .fadeIn(). I have created a good example here where you see 3 effects syncronyously done on 2 different divs: jsfiddle.net/9Ncrr/1 - Elisabeth

damn... I do not understand this, but the above sample link points to an old updated code. Seems something went wrong with copy/paste dont know or someone deleted the fiddle if thats possible at all. - Elisabeth

i think you forgot to update your fiddle.. anyways hope you fixed it and this helped.. happy coding - bipen

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.