myrandom
myrandom

Reputation: 33

jQuery .load() wait, before load content

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

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

Upvotes: 3

Views: 1122

Answers (1)

Paolo Bergantino
Paolo Bergantino

Reputation: 488704

Use callbacks:

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

Upvotes: 8

Related Questions