I have a JS timer script that counts down from 20 seconds
var count = 0;
var speed = 1000;
countdown = setInterval(
function(){
jQuery("#countdown").html(count);
if (count == 0) {
return;
}
count--;
}
,speed);
Is there a way to dynamically change the src of an image when the timer gets to a certain point? Eg:
if (count >= 0 && count <= 10) {
img.src = "2.png"
}
if (count >= 11 && count <= 20) {
img.src = "1.png"
}
When the user clicks a button it adds 5 to the count on the timer:
jQuery('#add').click(function() {
if(count >= 0 && count <= 18) {count = count + 6}
So when the value goes above 11 again the image src should revert back to 1.png
Basically its a script that changes a image's src according to the value of timer.
Thanks