user3142695
user3142695

Reputation: 17352

Do something after all elements are slideDown

With the code above I want to slide each container with a constant speed (not duration). Now I want to do something else after ALL container are open. How do I do that? Right now I would do something else after the first slide has been finished. That's not what I'm needing.

var constant = 4;
$('.box > .content').each(function() {
    $(this).show();
    var boxheight = $(this).height();
    $(this).hide();
    $(this).slideDown(boxheigt * constant, function() { 
        // Do something
    });
});

Upvotes: 1

Views: 102

Answers (1)

roydukkey
roydukkey

Reputation: 3288

How about something like this?

var constant = 4, count = 0;

$('.box > .content').each(function() {
    count++;

    $(this).show();
    var boxheight = $(this).height();
    $(this).hide();

    $(this).slideDown(boxheigt * constant, function() { 
        count--;
        if(count == 0)
            // Do something
    });
});

Upvotes: 1

Related Questions