FAFAFOHI
FAFAFOHI

Reputation: 909

javascript display text then after some time display new text

i'm not really sure what to call it or what to search for on google. I am trying to accomplish the task of displaying some text and after a desired amount of time display some new text.

something like this

"There is an active code." (4 minutes 32 seconds remaining) <- countdown showing remaining time

then say after 10 minutes remove "There is an active code." (4 minutes 32 seconds remaining)" and show

"Code has expired."

I would like to be able to edit the minutes and seconds so that i various countdowns

Upvotes: 1

Views: 4427

Answers (2)

SavoryBytes
SavoryBytes

Reputation: 36236

I would take a look at something this this

<script language="JavaScript">
TargetDate = "12/31/2020 5:00 AM";
BackColor = "palegreen";
ForeColor = "navy";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
FinishMessage = "It is finally here!";
</script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>

Upvotes: 0

JaredPar
JaredPar

Reputation: 754763

You're looking for the setTimeout method. This will execute a function after a specific period of time.

// setTimeout uses milliseconds. 
var oneSecond= 1000;
var tenMinutes = oneSecond * 60 * 10;

setTimeout(function() {
  // Change the text here
  }, tenMinutes);

The setTimeout method will fire once after the specified time. If you want it to fire on a regular basis, say every X seconds, then use setInterval instead

Upvotes: 4

Related Questions