How to call a function right after a slide effect?

2

I need to get the height of a div and re-think an ifram according to the current height, so far so good.

I'm just picking up the height right after a click that gives a slideToggle in this div. And it seems to me that as yet the slide effect has not finished I can not seem to get the right height.

So how do I call this function only after the slide is complete?

$(document).on("click", "#toggleDiv" function(){
    $("#questao").slideToggle(300);
    // chamar função para pegar altura somente após o fim do slide. como?
}); 
    
asked by anonymous 29.12.2014 / 17:23

1 answer

3

.slideToggle () accepts a callback , ie a function that should run when the animation is finished.

You can use this:

$(document).on("click", "#toggleDiv" function(){
    $("#questao").slideToggle(300, function(){
        // aqui o slide já acabou
    });

});

Within this function you can use this to access animated element. If you want the height you can use $(this).height();

    
29.12.2014 / 17:24