I want to dynamically load the src from This Person Does Not Exist for multiple img objects on the DOM.
When using the jquery attr function, every img object contains the same image. I want each object to contain a "refreshed" image.
I have successfully managed to get it to work using setTimeout
but would prefer if I didn't have to wait for them to load.
$(document).ready(function() {
var time = 0;
$('.imgDNE').each(function(e) {
time+=2000;
var obj = $(this);
window.setTimeout(function() {
$(obj).attr("src","https://thispersondoesnotexist.com/image?"+ new Date().getTime());
},time);
});
});