Browse - Programming Tips - jQuery: do something when an image is loaded

Date: 2018jun22
Library: jQuery
Language: javaScript
Keywords: onload

Q.  jQuery: do something when an image is loaded

A.

$('#myimg').on('load', function() { const width = $(this).width(); const height = $(this).height(); console.log('My image is loaded, size=' + width + ' x ' + height); });
Not to be confused with the load() function.