-2

I'm making a website that projects how many seconds left until Christmas. I made some of it, but I don't know a lot of javascript. It does work a little bit, but it just skips to zero and not one at a time. The thing is, I have no idea how to do it. I have searched and found about a function called setTimeout but when I use it, it just doesn't load and just crashes.

any help is needed

function counter(timeLeft) {

    while (timeLeft > 0) {
        timeLeft = timeLeft - 1;
        $(document).ready(function() {
            $(".time").text(timeLeft);
        });
        return;
    }

}

counter(1500);
DevOffline
  • 77
  • 7

1 Answers1

0

Get rid of the document ready event listener and get rid of the return statement. There really is no point in the return statement in the above code.

Coder365
  • 26
  • 2