Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set height on element after a slidedown()

i got a click thats triggers a slideDown() on a div. my thought is that after the div is expanded i set the height of another div based on the expanded div. The problem becomes that it takes the height and sets it before the other div is slided fully, for a fact it takes the height of the div that it got before it slide out.

is there a way to pause everything until the slideDown() is done?

$div.slideDown();

//sets the height of the Container
$outer_container.css("height", $inner_container.outerHeight());
like image 804
Dejan.S Avatar asked Nov 28 '25 23:11

Dejan.S


1 Answers

Use the callback function, which only runs once the animation is complete:

$div.slideDown(400, function() {
    //sets the height of the Container
    $outer_container.css("height", $inner_container.outerHeight());
});

Or, to use a slightly more compact apprach:

$div.slideDown(400, function() {
    $outer_container.height($inner_container.outerHeight());
});
like image 140
Blazemonger Avatar answered Dec 01 '25 13:12

Blazemonger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!