setTimeout() is not waiting [duplicate]

setTimeout(countdown(element), 1000); executes your function with that argument and passes the result into setTimeout. You don’t want that.

Instead, execute an anonymous function that calls your function:

setTimeout(function() {
    countdown(el);  // You used `el`, not `element`?
}, 1000);

Leave a Comment