That's because the animations don't wait. Add the css() to the last element's animation callback
function nexthour(object, start, stop) { var $guide = $("#guide"), $divs = $('div.bla'), ln = divs.length; $guide.css('height', $guide.height()); $divs.each(function(index) { $(this).fadeOut(1000, function() { $(this).remove(); var showid = $(this).attr('id'); showid = showid.replace('guide', ""); startchan(showid, start, stop, 'lame'); }); if (index==ln) $guide.css('height','auto'); //fire only for the last element }); return false; } On Feb 27, 9:54 am, Terpz <psy...@sygko.net> wrote: > Hi > > First, the code:http://pastebin.com/m142fb6a4 > > The $("#guide").css('height', 'auto'); runs when i run the function, > and after it changes to auto, it runs the each. > So, how can i be sure that it has run the each, before it runs > something else in my function? > > // Martin