(Solved) Changing text displayed at end of countdown in timer script

I’m using a timer script that I’d like to change the displayed text when the countdown ends but have no idea how to accomplish it. I’d appreciate any help I can get. Here’s the code I’m using:

   <p> The Update will be done in <span id="countdowntimer">20 </span> Seconds</p>
        
   <script type="text/javascript">
          var timeleft = 20;
          var downloadTimer = setInterval(function(){
          timeleft--;
          document.getElementById("countdowntimer").textContent = timeleft;
             if(timeleft <= 0)
                clearInterval(downloadTimer);
            },1000);
    </script>

Thanks in advance.

Fixed by adding second if statement like this:

<p id="test"> The Update will be done in <span id="countdowntimer">10 </span> Seconds</p>
        
          <script type="text/javascript">
                var timeleft = 10;
                var downloadTimer = setInterval(function(){
                timeleft--;
                document.getElementById("countdowntimer").textContent = timeleft;
                if(timeleft <= 0)
                   clearInterval(downloadTimer);
                if(timeleft == 0)
                   document.getElementById("test").textContent = "Update Complete";   
                },1000);
                  
            </script>
        
Sponsor our Newsletter | Privacy Policy | Terms of Service