$('.open').toggle(function () { $('.obj').animate({ top: "0" },500); },function () { $('.obj').animate({ top: "-8%",},500); });
$('.open').on('click',function(){ var isToggled = $(this).data('isToggled'); if(isToggled){ $('.obj').animate({ top: "-8%",500); } else { $('.obj').animate({ top: "0" },500); } $(this).data('isToggled',!isToggled) });