How to Check if Image is Loaded or not in jQuery?
In this post, I will show you how to check if the image is successfully loaded using jquery. If you need to check if the image is loaded on page load then this post is for you.
In this post, I will show you an example of how to check if the image is successfully loaded using jquery. If you need to check if the image is loaded on page load then this post is for you. Sometimes we need to check and display to the user if a specific image element was loaded successfully.
Here is the code example:
<script type="text/javascript">
$('.your_image_class')
.load(function(){
console.log("Image loaded succesfully!");
})
.error(function(){
console.log("Error occurred when loading image.");
});
</script>
I hope it helps. Thank you for visiting :)
Leave a Comment