How to check the full images loading in the container?

Hello!

There is a function that checks the element appears on the page:

( function check() {
 var element = $( '.j-e-text' );
 if( element.length ) {
 $( '.j-e-text' ).prepend( '<h1 style="font-size: 200px;">Hooray!</h1>' );
window.stop();
 } else {
 setTimeout( check, 100 );
}
})();


Please tell me how to add check if image is loaded directly inside the container (if they are there)?

Found method HTMLImageElement.complete and rewrote the function like this:

( function check() {
 var element = $( '.j-e-text' );
 if( element.length && HTMLImageElement.complete ) {
 $( '.j-e-text' ).prepend( '<h1 style="font-size: 200px;">Hooray!</h1>' );
window.stop();
 } else {
 setTimeout( check, 100 );
}
})();


But, so it checks the image is not in this container, but everything on the page. And secondly, do any special testing for the very presence of the images in this container or method HTMLImageElement.complete he will verify?

Thank you!
July 2nd 19 at 13:22
0 answer

Find more questions by tags jQuery