Animate element to auto height with jQuery

Save the current height: var curHeight = $(‘#first’).height(); Temporarily switch the height to auto: $(‘#first’).css(‘height’, ‘auto’); Get the auto height: var autoHeight = $(‘#first’).height(); Switch back to curHeight and animate to autoHeight: $(‘#first’).height(curHeight).animate({height: autoHeight}, 1000); And together: var el = $(‘#first’), curHeight = el.height(), autoHeight = el.css(‘height’, ‘auto’).height(); el.height(curHeight).animate({height: autoHeight}, 1000);

How to fade animate background images (full size) [closed]

This is how I would do it with a couple of jQ lines: var $bg = $(‘#bg’), $bgDIV = $(‘div’, $bg), // Cache your elements n = $bgDIV.length, // count them (used to loop with % reminder) c = 0; // counter (function loopBG(){ $bgDIV.eq(++c%n).hide().appendTo($bg).fadeTo(3000,1, loopBG); }()); // start fade animation *{margin:0; padding:0;} body{ width:100%; … Read more