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?
jQuery slideUp() MethodThe slideUp() method slides-up (hides) the selected elements. Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: To slide-down (show) elements, look at the slideDown() method.
The slideDown() Method in jQuery is used to check the visibility of selected elements or to show the hidden elements. It works on two types of hidden elements: Elements hidden using jQuery methods. Elements hidden using display: none in CSS.
The jQuery slideDown() method is used to slide down an element. Syntax: $(selector). slideDown(speed,callback);
The slideUp() is an inbuilt method in jQuery which is used to hide the selected elements. Syntax: $(selector). slideUp(speed); Parameter: It accepts an optional parameter “speed” which specifies the speed of the duration of the effect.
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.
if($(this).next('.nxt_div').height()>1){ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With