views:

25

answers:

1

I have the following code:

$('a.btn-slide').toggle(function() {
    $("#DivToSlide").slideUp("fast");
    // ...
}, function() {
    $("#DivToSlide").slideDown("fast");
    // ...
});

Later in my code, I want to find out if #DivToSlide is in either the up or down position.

How do I do that?

+3  A: 

Since the slideDown function hides the element after it finishes, you can simply check whether the element is visible:

if ($('#DivToSlide').is(':visible'))

You could also check whether $('#DivToSlide').height() is more than some threshold.

SLaks
Why should I *"check whether $('#DivToSlide').height() is more than some threshold."*?
JGreig
Just doing *if ($('#DivToSlide').is(':visible'))* works
JGreig
In case it's in the middle of animating.
SLaks
Upvoted for the height() trick, I was just looking for a way to do this earlier today.
HurnsMobile
Can't you check to make sure it's not `:animated`? Then recheck again if it is? - http://api.jquery.com/animated-selector/
fudgey
@fudgey: That depends on what he's trying to do.
SLaks