In a nutshell, I want the callback to start after the html has been added and the contents of that html is displayed. The reason is that I need to immediately know the height of the new content. Something like that:
$('div').html(tonsofstuff); console.log( $('div').height() ); //works in Firefox, but returns 0 in Chrome setTimeout(function(){ console.log( $('div').height() ); //works everywhere, but takes too long },3000);
The problem occurs in some browsers (and always in chrome) $ ('div'). height () is triggered before the new content has a height.
My fantasy:
$('div').html(tonsofstuff, function(){ console.log( $('div').height() ); }); or even $('div').html(tonsofstuff).load(function(){ console.log( $('div').height() ); });
source share