0

is there a way to get the state of the slider wheather it is slideUp() or sliderDown() .

suppose if I were to user slideToggle()

$(document).ready(function(){
  $(".flip").click(function(){
    $("#panel").slideToggle("slow",showstate);
       function showstate(){


        }
  });
});
atari400
  • 91
  • 1
  • 4
  • 11

2 Answers2

1
if ($("#panel").is(":visible") == true){ 
 $("#panel").slideDown();
}
else {
 ("#panel").slideUp();
}
Alex Kneller
  • 413
  • 4
  • 15
1

If the element has been sliden up then it will have in line styles that equal display:none

$(document).ready(function(){
  $(".flip").click(function(){
    $("#panel").slideToggle("slow",showstate);
       function showstate(){
               if($(this).attr('style')==="display: none;"){
                  //slideUp state
               }
    }
  });
});
Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
  • thanks a lot sir! but why is line 5 having === instead of == ? – atari400 Jul 10 '13 at 08:25
  • 1
    In short its just a little bit more security on the `if`, it basically means if the type is a sting and it equals the given string. I'd have a look at using JSHint or JSLint if you really want to go to town. – Jamie Hutber Jul 10 '13 at 08:27
  • @atari400: glance your eyes over the second answer on this question and you will understand == vs ===: http://stackoverflow.com/questions/523643/difference-between-and-in-javascript – DerpyNerd Apr 08 '16 at 12:22