<img src="someimage.jpg" alt="thumbnail" />
I'm changing the src
attribute of this image dynamically.
How do I check whether the image was loaded or not? And do something when it is loaded.
Thanks.
Start here: http://forum.jquery.com/topic/simple-image-load-detection-with-load
The above assumes you are loading the image from JQuery and that is where you need to attach your additional code.
you can handle the load event with...
$('#id').load(function(){
//handler code here
});
If you only want to handle when it is changed...
$('#id').attr('src','yourimage.png').load(function(){
//handler code here
});
var link = 'http://i.treehugger.com/images/2007/5/24/120_mph_electric_car.jpg';
$('img').attr('src',link).load(function(){
alert('image loaded');
});