Similar Inquiry:
jQuery check if image is loaded
I find myself in a scenario where the following HTML structure is utilized:
<div class="image">
<img class="" src="content-images/1.jpg">
<span class="slide" rel="content-images/2.jpg"></span>
<span class="slide" rel="content-images/3.jpg"></span>
<span class="slide" rel="content-images/4.jpg"></span>
</div>
All children of div.image
are absolutely positioned in the CSS, causing them to overlap each other.
My objective is to switch the span
elements with img
ones and set their src
attribute to the value specified in the rel
attribute within each span. These images are large and high resolution, so they may take some time to load completely.
Using JavaScript or jQuery, I need to display a loading message or indicator from when a button is clicked elsewhere on the page until all the span
elements have been replaced with img
elements and finished loading.
Due to issues with images and caching, using jQuery's .load()
method is not feasible in this case.
While attempting to use imagesloaded, it did not provide the functionality I require.
Are there any alternative methods you can suggest to achieve this task?