Created
August 25, 2015 18:44
-
-
Save patriziosotgiu/89325b0aa0e32fde207d to your computer and use it in GitHub Desktop.
jQuery - Check when all img and iframe of a div are loaded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get height of the block when all elements are loaded | |
// This fixes some bugs with lazyload in some browsers, and slow connections | |
var $elements = $('#div').find('img, iframe'); | |
var elementsCount = $elements.length; | |
var loadedCount = 0; | |
$elements.on('load', function () { | |
loadedCount++; | |
if (loadedCount === elementsCount) { | |
getSetHeight(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice one!