I want to show the content after image_1 and image_2 are completely loaded. But, it is not working as expected
var loading = 0;
(function() {
$(".image_1").on('load', function() {
console.log('loading image_1');
loading++;
checkLoading();
});
$(".image_2").on('load', function() {
console.log('loading image_2');
loading++;
checkLoading();
});
})();
function checkLoading() {
console.log('inside Loading check');
if (loading == 2) {
console.log('loading done' + loading);
$('#loader-wrapper').fadeOut('fast').remove();
}
}
This function is not working all the time. It is added in the footer of php file.
Sometimes, it removes the #loader-wrapper successfully. But few other times, #loader-wrapper is not removed from DOM and I don't see any console.log info on that time.