Answer the question
In order to leave comments, you need to log in
How to add src to all images?
Hey! I create a form for uploading pictures, everything is fine, but the pictures after the replacement have the same address, respectively, until you clear the cache - you see the old picture. Found a solution:
$(function() {
var a = $('.reload-img img').attr('src');
$(".reload-img img").attr("src", (a) + "?" + Math.random());
});
Answer the question
In order to leave comments, you need to log in
$('.reload-img img').each(function () {
const src = $(this).attr('src')
$(this).attr('src', `${src}?${Math.random()}`)
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question