Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click on the button below. The input field will tell you when two, four, and six seconds have passed.</p> <button onclick="timedText()">Display timed text</button> <input type="text" id="txt"> <script> function timedText() { var x = document.getElementById("txt"); setTimeout(function(){ x.value="2 seconds" }, 2000); setTimeout(function(){ x.value="4 seconds" }, 4000); setTimeout(function(){ x.value="6 seconds" }, 6000); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_settimeout2 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:28:05 GMT --> </html>
Result:
Try it Yourself - © w3schools.com