In this article, we will learn how to refresh an image using javascript or jquery.
A few days back, I was facing a problem and the problem was that image URL was changed on button click event in jquery but the image is not refreshed. This problem happens due to these two reasons:
In my case, my browser caching the image and this problem could be solved by forcing the browser to reload the image by passing an extra variable like so:
d = new Date();
$("#myimgID").attr("src", "/myimgURL.jpg?"+d.getTime());
I hope this article will help you to understand how to refresh an image using javascript or jquery.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments