How to check if an image is loaded with jQuery

The following jQuery code can be used to detect if an image is loaded successfully or not. In this snippet we are using load and error events.

See All: Equalize Heights of Divs

Click here to view the demo.

//Check whether image is loaded with jQuery
		console.log("Image loaded correctly");
		console.log("Error in loading image");

If the image is loaded successfully, load event is triggered, else error event is triggered.


Leave a Comment.