What it is writing a <p> in place of or under/ after and image while the image is downloading / loading. But when the image is fully loaded, that <p>in is hidden.
Also that <p>just has text in it.
Does anyone have any idea how to do this and would be willing to help?
Thanks in Advance & Best Regards,
You need to provide a bit more detail. Is the image being loaded using AJAX? Or is the image in place when the page loads, and you just want to show something in the <p> while the page loads, then hide it once the image has finished loading?
image in place when the page loads, and you just want to show something in the <p> while the page loads, then hide it once the image has finished loading?
This except, if possible, not while the page loads while that exact image loads.
I'm sorry for any misunderstanding or confusion
You could do something like this in your page:
<img src="images/myImage.jpg" alt="My Image" width="400" height="300" />
<p class="loading">Please wait while the image loads...</p>
If you give it a width and height, the browser will show a placeholder of the correct size until the image has "arrived." That way the layout doesn't shift or change once the image has been downloaded.
Then make sure jQuery is loaded and then do something like this:
// Do something after images are loaded
Note that this will wait for all images on the page to load. There are other methods to determine if a particular image has loaded, but hopefully this points you in the right direction.
yes this does. thank you. and by other method to determine if a particular image has loaded, you mean $(".image").load() right?
Yeah, that's one way, but it's a bit flakey. I did something like that in the past when coding up an image gallery, but had to resort to a plugin that had better cross-browser support. It was probably just to support IE6 or something, so you may be fine....
What is the other way to do it, if you don't mind me asking?
There's a discussion [here on the topic. Looks like an updated version of the plugin I used is [URL="https://github.com/desandro/imagesloaded"]here](http://forum.jquery.com/topic/simple-image-load-detection-with-load).
This topic is now closed. New replies are no longer allowed.