Wiat for fadeOut to complete its effect then execute fadeIn effect

I have these two effects in my script.

$("#imgContainer").fadeOut(500);
$("#b").fadeIn(500);

I want the wffect of $("#b").fadeIn(500); after the first one completes its effects fully. How can i do it.

I have tried this

setTimeout(
  function() 
  {
    $("#imgContainer").fadeOut(500);
  }, 500);

but not worked.

I have also tried this $("#imgContainer").fadeOut(500).delay(500);

Answers


$("#imgContainer").fadeOut(500,function(){
   $("#b").fadeIn(500);
});

Try using the callback function,

$("#imgContainer").fadeOut(500,function(){ $("#b").fadeIn(500); });

Need Your Help

Multiple modules List in a Dashboard - Yeoman MEANJS Generator

angularjs node.js yeoman meanjs mean.io

I am new in MEANJS and someone suggest me to go with MEANJS for kickstart app. I have started working on it and trying to make an architecture for my app but i am confused in 1 thing that what will...