How to make SlideUp stop at acertain height

Greg  picture Greg · Nov 23, 2011 · Viewed 9.3k times · Source

I'm using a slideUp and slideDown plugin. I was wondering how i can make it so the div only slide ups to a certain height.

Second question How can I make my the same button the target for the div to slide up and down?

Here's what I m currently trying to use

$(document).ready(function() {

  $("#toggle").click(function(){
     $("#Menu").slideDown( 'slow', function(){ 
         $(".log").text('Slide Down Transition Complete');
      });
  });

  $("#toggle").click(function(){
     $("#Menu").slideUp('slow', function(){ 
         $(".log").text('Slide Up Transition Complete');
      });
  });

});

Answer

timing picture timing · Nov 23, 2011

In this case you could create a custom animation for slideUp. Let's say you want to slideUp to a height of 20px:

$("#toggle").click(function(){
    $("#Menu").animate({height: 20}, 'slow', function(){ 
        $(".log").text('Slide Up Transition Complete');
    });
});