jQuery or JavaScript: Determine when image finished loading

Francisc picture Francisc · Dec 20, 2010 · Viewed 30.1k times · Source

How can I detect when an image has finished loading be it from the server or the browser cache? I want to load various images in the same <img/> tag and detect when the loading of a new images has finished.

Thank you.

Answer

Matthew picture Matthew · Dec 20, 2010
$('img').on('load', function() {
    // do whatever you want
});