JQuery.load () wait, before loading content

I would like to fadeOut # a wrapper portfolio than load portfolio2.html with fadeIn (600). The problem is that the load function is executed before fadeOut (600). Please help me! Many thanks:)

$("a").click(function(){
    $("#portfolio-wrapper").fadeOut(600).load('portfolio2.html').fadeIn(600);
});

      

+3


source to share


1 answer


Use callbacks:



$("a").click(function(){
    $("#portfolio-wrapper").fadeOut(600, function() {
        $(this).load('portfolio2.html', function() {
            $(this).fadeIn(600);
        });
    });
});

      

+8


source







All Articles