Computer Magic Logo
Check if images are loaded

Friday, January 22, 2016

Published by Aristotelis Pitaridis

Sometimes we need to check if the images have been loaded in order to execute commands related to the images.

$('img').load(function() {
    // images loaded successfully

We canĀ also check if one specific image has loaded by using the element's id or class.

$('#MyImage').load(function() {
    // image loaded successfully