Load event for images added dynamically to #div are not working, whereas other events like click/mouseover etc are working fine.
<div id="test">
<img src="https://via.placeholder.com/50" />
</div>
js
$(document).ready(function() {
// does not work
$('#test').on('load', 'img', function() {
alert('loaded');
});
// work fine
$('#test').on('click', 'img', function() {
alert('clicked');
});
setTimeout(() => {
$('#test').append('<img src="https://via.placeholder.com/150" />');
}, 1000);
setTimeout(() => {
$('#test').append('<img src="https://via.placeholder.com/250" />');
}, 2000);
setTimeout(() => {
$('#test').append('<img src="https://via.placeholder.com/350" />');
}, 3000);
});
check fiddle: https://jsfiddle.net/zkpt2crg/ any way to detect load event of dynamic elements?