Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery: How to determine if Slide event is up or down?

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?

like image 555
JGreig Avatar asked Apr 26 '10 21:04

JGreig


People also ask

What is slide up and slide down in jQuery?

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.

What does slideDown do in jQuery?

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.

Which jQuery method is used to slide down an element?

The jQuery slideDown() method is used to slide down an element. Syntax: $(selector). slideDown(speed,callback);

What is slideUp in jQuery?

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.


2 Answers

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.

like image 194
SLaks Avatar answered Sep 20 '22 14:09

SLaks


if($(this).next('.nxt_div').height()>1){ } 
like image 33
Avinash Saini Avatar answered Sep 18 '22 14:09

Avinash Saini