-1
function updateCounter(){
    console.log(delay);
    delay = delay - 1000;
    $('#counter-value').html(delay / 1000);
    if(delay <= 0){
        clearInterval(loopID);
    }
}
var delay = 5000;
var loopID = setInterval(updateCounter(), 1000);

I don't understand why it doesn't work, could someone help me? I've looked many things but couldn't end up making it. :(

1 Answers1

2

You need to pass the function name or reference--remove ()

var loopID = setInterval(updateCounter, 1000);
Adam Azad
  • 11,171
  • 5
  • 29
  • 70