This is my code:
function transition(index){
$("#right-panel").find("img").each(function(){
if ($(this).index() === index){
setTimeout(function(){
$(this).fadeIn(750);
}, 100000000);
}else{
$(this).fadeOut(750);
}
});
}
For some reason, the setTimeout in the function is not causing a delay for the fadeIn. What am I doing wrong?
thisin thesetTimeoutcallback isn’t the same as outside it.Although you could just use
.delay().Overall a better approach would seem to be to use
.eq()to grab the one you want to.fadeIn(), and.fadeOut()the rest.