I have multiple images in a single div
and I want to take some action only when all images in this div
are loaded, which sounds simple but I was unable to find any neat solution to do this.
<div class="imgs">
<img src="img1.jpg">
<img src="img2.jpg">
<img src="img3.jpg">
</div>
I found Official way to ask jQuery wait for all images to load before executing something which suggests to use $(window).on("load", function(){})
, but I have multiple div
and I want to take action as long as all images in each div
are loaded, not when all images in the DOM are loaded.
I also found some JavaScript way to do it, such as jQuery or Javascript check if image loaded and How to make Javascript wait for all images to load before proceeding?, which are quite complicated for such an seemingly easy task.