How to Check Image Loaded or Not in JQuery?

By Hardik Savani April 8, 2023 Category : jQuery

When it comes to optimizing your website for search engines, it's important to ensure that all images are loaded properly. This is where jQuery comes in handy. With jQuery, you can easily check if an image has been loaded or not using the "image loaded" event. To check if an image has been loaded successfully, you can use the jQuery "image load" event. Alternatively, you can also use the "image load error" event to check if an image has failed to load. However, if you find that the "image load" event is not firing, it may be due to a number of reasons, such as caching or errors in your code. To help you get started, here's a jQuery load event example that you can use to check if an image has been loaded or not:

Example:

<script type="text/javascript">

$('.image')

.load(function(){

console.log("Now loaded correctly");

})

.error(function(){

console.log("Found Error in loading image");

});

</script>

I hope it can help you...

Tags :
Shares