I have a list of images as buttons and when clicked a modal appears that has the image on the left with text on the right. But when I switch the src of the image in the modal the browser refetches the image from the database. Is there a way to switch the image without refetching since it has already been downloaded?
$(button).on("click", function () {
// GET ALL THE INFO NEEDED FOR THE CARD
const imgURL = this.querySelector("img").src;
const name = this.querySelector(".__name").innerHTML;
const position = this.querySelector(".__position").innerHTML;
const questions = this.querySelectorAll('[data-js="question"]');
const answers = this.querySelectorAll('[data-js="answer"]');
// POPULATE THE CARD
employeeCard.querySelector(".__name").innerHTML = name;
employeeCard.querySelector(".__position").innerHTML = position;
employeeCard.querySelector(".__img").src = imgURL;
// CONSTRUCT ANSWERS AND QUESTIONS
// SHOW THE CARD AFTER 200 MS
setTimeout(() => {
$(employeeCard).toggleClass("active");
}, 200);
});
for the fact that the browser refetches the image on change. Thanks for answers in advance.