Nico baruna

professional web developer

how to toggle slide with specific width

see the picture , when we click the arrow the content box should shrink to specific width , like this

when i try to toggle slide my box to specific width i got problem  because jquery animate() function only give us slide-to-zero-width option or slide-to-specific-width but we cant make it toggle

ex :

$(“Selector”).animate(function(){

width : toggle;

});

or

$(“Selector”).animate(function(){

width : 25;

});

this make me mad , and frustrated i think there’s must be an easy way to do this, then i try jquery toggle() function and Voila!! its work :

$(‘.toggle’).toggle(function() {
                                         var $parent = $J(this).parent();   
                                         $parent.animate({
                                          width:’25’
                                         },function(){
                                             $parent.addClass(“minimised”);
                                         });
                                       
              }, function() {
                                         var $parent = $J(this).parent();   
                                         $parent.animate({
                                          width:’325’
                                         });
                                         $parent.removeClass(“minimised”);
                   

              });

$parent.addClass(“minimised”); —> this add new class that flip the arrow image