+ 1
Read description
So I want the second message to appear like 5 or so seconds later after the first message. How can I achieve this? (type "TheEnd" in the input box) https://code.sololearn.com/W24N68LyD1ho/?ref=app
5 Respuestas
+ 3
Hello, Daniel Cooper !
Use "setTimeout(EasterEggMessage, 5000);"
Instead of setDelay()
Because setDelay() does not exist.
/*
For Example
*/
function Events() {
document.getElementById("input").addEventListener("keyup", TextOne);
}
function TextOne() {
var EasterEgg = document.getElementById("input").value;
document.getElementById("output").innerText = document.getElementById("input").value;
if(EasterEgg == "TheEnd") {
document.getElementById("output").innerHTML = "You've discovered my Easter Egg! <br/> <br/> Your reward is<span id='MySpan'>THE END OF ALL LIFE</span>";
/*This is setTimeout, Instead of setDelay()*/
setTimeout(EasterEggMessage, 5000);
EasterEggMessage();
}
}
window.onload = Events;
function EasterEggMessage() {
document.getElementById("output").innerHTML = "No, just kidding xD";
}
+ 1
Replace setDelay with setTimeout (line 13) and remove/comment line 14.
Make note that your EasterEgg function would do futher check if content its yet "TheEnd"
0
Can somebody give an example? I already tried setTimeout. I was trying setDelay because I couldn't remember if it was a thing or not. Neither of them worked. Anyway, I need an example of a working version.
0
Ok.Thanks guys! Check out the code. I updated it.