I am using same gif image twice in a page. Both the images will be hidden initially. Based on certain criteria I am showing those gif images (when clicked on particular target one gif image will be shown at a time). I am unable to reload the gif image. See the attached plunker
1) https://plnkr.co/edit/vqZCHkyq7zCRCLpe9osF?p=preview
<script>
var img1 = document.getElementById("img1");
var img2 = document.getElementById("img2");
function toggle1() {
if (document.getElementById('gif-1').style.display == "none") {
document.getElementById('gif-1').src = '';
document.getElementById('gif-1').src = 'http://insightgraphicdesign.net/wp-content/uploads/2014/07/coke-responsive-logo.gif';
document.getElementById('gif-1').style.display = "block";
} else
document.getElementById('gif-1').style.display = "none";
}
function toggle2() {
if (document.getElementById('gif-2').style.display == "none") {
document.getElementById('gif-2').src = '';
document.getElementById('gif-2').src = 'http://insightgraphicdesign.net/wp-content/uploads/2014/07/coke-responsive-logo.gif';
document.getElementById('gif-2').style.display = "block";
} else
document.getElementById('gif-2').style.display = "none";
}
</script>
But if I use one gif image it is working properly, see this plunker (sometimes it is not working may be plunker blocking due to security. better put it in a html and check)
2) https://plnkr.co/edit/74huqUZmkoc6T6BdNOlz?p=preview
<script>
var img1 = document.getElementById("img1");
function toggle1() {
if (document.getElementById('gif-1').style.display == "none") {
document.getElementById('gif-1').src = '';
document.getElementById('gif-1').src = 'http://insightgraphicdesign.net/wp-content/uploads/2014/07/coke-responsive-logo.gif';
document.getElementById('gif-1').style.display = "block";
} else
document.getElementById('gif-1').style.display = "none";
}
</script>
can anyone help me to make the plunker 1 to work? (both gif images should reload whenever I click the two buttons).
Thanks, HariKrishnan P