Reputation: 121
I do have a gif image load bar animation I do want it to reload when click Reload Image so that the animation will repeat.
//My HTML
<img src="http://i54.tinypic.com/2qdwtp0.gif" id="load-bar"/>
<a href="#" id="reloadImg">Reload Image</a>
//My js code
function imgRelaoder() {
//some stuff to reload image with id #load-bar
}
$(function() {
imgRelaoder();
$("#reloadImg").click(imgRelaoder);
});
Upvotes: 1
Views: 697
Reputation: 30891
function imgRelaoder() {
$("#load-bar").attr("src",
$("#load-bar").attr("src")
);
}
Upvotes: 0
Reputation: 3415
First, create an Image object and assign it a src property:
var image = new Image();
image.src = "path-to-your-loader.gif";
Then, in your function imgReloader:
$("#load-bar").attr("src", image.src);
Upvotes: 0
Reputation: 322492
$(function() {
var loadImg = document.getElementById('load-bar');
$("#reloadImg").click(function() {
loadImg.src = loadImg.src;
}).click();
});
Upvotes: 2