Home › Forums › JavaScript › Jquery fade/toggle only works on first click… › Re: Jquery fade/toggle only works on first click…
July 15, 2011 at 7:12 pm
#83467
Mottie
Member
Hmm, ok try this:
var ht = $('#panel').height();
$('#panel').height(0);
$('#info').hide();
$(".btn-slide").click(function() {
var d = $('#info').is(':hidden');
if (!d) { $('#info').fadeOut(200); }
$('#panel').animate({ height: (d) ? ht : 0 }, 500, function(){
$('#info')[(d) ? 'fadeIn' : 'fadeOut']();
});
$(this).toggleClass("active");
return false;
});
I changed it from slideToggle because adding a callback seemed to fast-forward the slidedown animation.