Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery refresh image without refreshing page

// you can simply append a random string at the end of the image URL. 
// This will cause the browser to treat the URL as a different URL and avoid retrieving the cached version.
$(document).ready(function() {
    $("button").click(function() {
        var url = $("#container").attr("src");
        $("#container").attr("src", url + `?v=${new Date().getTime()}`);
    });
});
 
PREVIOUS NEXT
Tagged: #jquery #refresh #image #refreshing #page
ADD COMMENT
Topic
Name
2+1 =