treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] JQuery animate() function

  • $("#resizer").click(function(){
            if($("#slider").height()=='300px')
            {
              $("#slider").animate({height:'650px'});
              $("#slider-container").animate({height:'650px'});
            }
            else
            {
              $("#slider").animate({height:'300px'});
              $("#slider-container").animate({height:'300px'}); 
            }
          }); 
    

    It simply doesn't work. No visible effect. Do you have any idea what did I miss?

  • Try adding a duration to the animations. For example…

    $("#resizer").click(function(){
          if($("#slider").height()=='300')
          {
            $("#slider").animate({height:'650'}, 600);
            $("#slider-container").animate({height:'650'}, 600);
          }
          else
          {
            $("#slider").animate({height:'300'}, 600);
            $("#slider-container").animate({height:'300'}, 600); 
          }
        }); 
    

    600 = 600ms

  • That, along with removing 'px' from the values did it! Thank you!