I am creating a game that when the play button is clicked, the timer starts. When my time is 0
I want to the paragraph with #timeline
to be replaced with different text, which works perfectly. However how can I simultaneously add a .class
to the replacement text so I can style "Your time is up!" differently when it is displayed.
var secondsLeft = 20;
function startTimer(){
setInterval(myTimer, 1000);
}
function myTimer(){
if(secondsLeft!=0){
document.getElementById("time").innerHTML = secondsLeft-=1;
} else {
document.getElementById("timeLine").innerHTML = "Your time is up!";
}
}