+ 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

4th Jul 2018, 7:48 AM
Daniel Cooper
Daniel Cooper - avatar
5 Réponses
+ 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&apos;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"; }
4th Jul 2018, 7:53 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 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"
4th Jul 2018, 7:55 AM
KrOW
KrOW - avatar
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.
4th Jul 2018, 9:51 AM
Daniel Cooper
Daniel Cooper - avatar
0
Ok.Thanks guys! Check out the code. I updated it.
4th Jul 2018, 7:19 PM
Daniel Cooper
Daniel Cooper - avatar